Loop within currently displayed taxonomie

Hello!

I’m currently working on a website where we want a looper within different taxonomies. I’ve come a long way but at the moment I’m stuck.

Different types of training are displayed on the website. Example, In the training category “programming” we have training A and training B. I have created a looper that allows us to display training A and B in a table. If one clicks on Training A they go to a detail page about this training. This works fine.

The problem is on the detail page for the training.

I would like to create a looper here in which we can list the different dates and locations in a table.

I made a layout for training detail page. When I set the looper in this there is no option to loop within the taxonomy currently displayed. I get to see the times and locations of all classes, or all times and locations of all classes within the “programming” category.

Is there an option for us to loop with the currently displayed training?

I was thinking in an array, something like this;

Posttype=training&TrainingType=programming&class=trainingA

Looking out for your response,

Thanks.

Hello @djkranendonk,

Thanks for writing in!

The Looper Provider Query String should be used in your custom loop within the Taxonomy archive page to resolve your issue. You will need to have a Query argument that displays the custom post type “Training” with the training type “Programing” and with the class “Training A”. It may look like this:

$args = array(
    'post_type' => 'training',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'type',
            'field'    => 'slug',
            'terms'    => 'programming',
        ),
        array(
            'taxonomy' => 'class',
            'field'    => 'slug',
            'terms'    => 'trainingA',
        ),
    ),
);

Perhaps this thread can be your reference then:

Kindly let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.