Home › Forums › Front-end Issues › Recall the tags that have a connection to the posts with field taxonomy › Reply To: Recall the tags that have a connection to the posts with field taxonomy
Hi @maxdel85
I’m still not sure about your goal, so please forgive me if I’m wrong.
I’m afraid you need to use wpdb to achieve it. You can query it to get all of the tags set to the CPT like this:
SELECT * FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'innovators') AND meta_key = 'taxonomy_field_name'
After that, you need to unserialize each row and combine them in one array. Then you can use array_count_values() to count the tags.
If you want to show the tags based on the custom posts, you need to loop the returned custom posts, get the taxonomy fields and put the IDs in one array. After that, you can use array_count_values() to count it.
I hope this makes sense.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.