Filter Looper Dynamic Posts by CPT UI Custom Taxonomy Terms

I’ve created a looper row with columns containing programs for a school. The programs are a CPT UI Post Type I created is called Programs. I’d like to filter these programs by their associated CPT UI Custom Taxonomy terms. The custom taxonomies I have are Program Grades and Program Locations.

I’ve created a dropdown for the Program Grades dynamically populating with all terms available.

What I’m trying to do is have it so that if you click any one of the filter terms, it will filter the posts below by the Program Grade term. So far I’ve got this in my URL field for each term button ?orderby=title&order=asc.

What do I need to add to the URL field in order to filter by the associated tag?

Hi @santosfel5,

Thanks for reaching out!

I suggest that you watch this video tutorial on how you can filter using the loopers.

Hope that helps.

Hi @marc_a

Thank you, I actually watched that video to create this current setup. He doesn’t go into using custom taxonomies terms though for filtering posts. That’s why I came here to ask what do I need to add to my URL field in order to filter posts that match the taxonomy term.

1 Like

Hello @santosfel5,

The video tutorial discusses how you can pull the Filter buttons using the Looper. It uses simple methods to filter by date or by title. If you need to use by category, you will have to still use the Looper Provider Query string something like:

post_type=post&tax_query%5B0%5D%5Btaxonomy%5D={{dc:url:param key="taxonomy" fallback="people"}}&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D={{dc:url:param key="terms" fallback="bob"}}

This was taken from this example Query:

// Display  **posts**  tagged with  **bob** , under  **people**  custom taxonomy.
$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        array(
            'taxonomy' => 'people',
            'field'    => 'slug',
            'terms'    => 'bob',
        ),
    ),
);
$query = new WP_Query( $args );

And then in your URL parameter, you will have to add:

?orderby=title&order=asc&taxonomy=people&terms=bob

Be advised that these codes are examples only and will not work out of the box. You will have to replace it according to your custom post type and taxonomy needs.

Best Regards.

@ruenel I think I’m almost there.

Query String
I took your string and updated it accordingly, but it’s now making the dynamic dropdown buttons disappear.

Here is the full Query String I updated:
post_type=programs&tax_query%5B0%5D%5Btaxonomy%5D={{dc:url:param key="taxonomy" fallback="program_grades"}}&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D={{dc:url:param key="terms" fallback="ages-14-21"}}

Button URL
This is the url I’m using for the looper term buttons. I need the term being pulled to be dynamic.
?orderby=title&order=asc&taxonomy=people&terms={{dc:term:title}}
The problem with above is that the {{dc:term:title}} is pulling the term title dynamically, but the term title not concatenated so the url is incorrect.

Hi @santosfel5,

I have added the {{dc:term:title}} into the Button URL and found it added the title into the URL. Please find the Test page URL in the secure note where I have added it.

Thanks

I just tested out the filter buttons on the test page you updated and they don’t appear to be working. If I click the College/Post-Secondary button it doesn’t show only College/Post Secondary posts.

Hello @santosfel5,

You will be using this for the button URL
?orderby=title&order=asc&program-terms={{dc:term:slug}}

And then use this for the query string:
post_type=programs&tax_query%5B0%5D%5Btaxonomy%5D={{dc:url:param key="taxonomy" fallback="program_grades"}}&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D={{dc:url:param key="program-terms" fallback="ages-14-21"}}

The program-terms is used to avoid conflict with the query string. Kindly check your site now.

Hey @HoodSiegal,

If you have any questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off-topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.

Best Regards.

Okay thank you, I will need to open a new thread because this did not achieve the desired result. The button URL is showing up correctly, but the results on the page are not.

Hi @santosfel5,

You are most welcome, please let us know once you create a new thread.

Thanks

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