Dropdown with auto populated categories and post count

Hey guys. Slow but steady is my motto here and I’m sorry if it’s a bit anoying. I’m still trying to wrap my head around Cornerstone loopers and ACF.

What I want to do is create a dropdown for a filter. I managed to set up the drop down, have a looper provider on it and withing the dropdown I want a button to loop over a specific ACF field to retrieve all available categories and a respective number of posts available for each category.

I’m struggling with the looper provider though. I used dynamic content with this {{dc:acf:post_field field=“kunstwerk_kategorie”}}. Now on the button I want to display the category name and count for that specific category. I only managed to get the first one using {{dc:post:meta key=“kunstwerk_kategorie”}}

How can I have them all displayed? I got 5 in total but only 2 are currently used in posts so I just want the categories with posts in them to show in the dropdown.

Hey Umberto,

Thanks for writing in! The best one you can try is to use the Terms element. This will display all the categories. and you can use this as your guide in your Looper. Check it out here:

You may need to use nested Looper on the idea that you have in mind so that you can display the total number of posts in each category.

Best Regards.

Ok I see. Does terms also apply to categories set through an ACF field? Or just with the native Wordpress ones?

Hello @umbertofederico,

It is best that you provide with us your WP details so we can check your data structure. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

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