Support

Account

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.