Query String - Custom Post Type and Taxonomy ACF

I want to get all items that are inside the ‘courses’ post type and inside the ‘dementia’ term using Query String (the Taxonomy is ‘training-course-type’).

It works with Query Builder when I put Courses in the Posts section and ‘Dementia’ in the Taxonomies section.
The reason I don’t want to use the Query Builder is because I want the taxonomies, or rather the term, to be Dynamic.

Here are the query strings I’ve tried:

post_type=courses&tax_query%5B0%5D%5Btaxonomy%5D=training-course-type&tax_query%5B0%5D%5Bterms%5D={{dc:term:name}}

post_type=courses&tax_query%5B0%5D%5Btaxonomy%5D=training-course-type&tax_query%5B0%5D%5Bterms%5D=dementia

taxonomy=training-course-type&tax_query%5B0%5D%5Bterms%5D={{dc:term:name}}

taxonomy=training-course-type&terms={{dc:term:name}}

None of them work to show all the courses in the term.

I know I’m the one who cannot figure it out using query string because using query builder works - so please could you give a hand or even give a step-by step tutorial on how to build a query string.

Thank you

Hey @bobbyninetoes,

Thanks for writing in!

You can use WordPress Query Generator to be more accurate in having the right query arguments. For example;

$tax_query = array(
    array(
        'taxonomy'         => 'training-course-type',
        'terms'            => 'dementia',
        'field'            => 'slug',
    ),
);

$args = array(
    'post_type'              => array( 'courses' ),
    'order'                  => 'ASC',
    'orderby'                => 'title',
    'tax_query'              => $tax_query
);

With this one, you can get the Query String that you can use for your looper. Please check out this thread to learn how to convert the query arguments into a query string.

Best Regards.

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