How to extract the tags shared between two different post types in Wordpress


/ Published in: PHP

Extract all the tags (shared between two post types) used with a specific post type


Copy this code and paste it in your HTML
  1. $articles_in_post_type = get_posts( array(
  2. 'fields' => 'ids',
  3. 'post_type' => 'post',
  4. 'posts_per_page' => -1,
  5. ));
  6. $tags = wp_get_object_terms( $articles_in_post_type, 'post_tag', array('ids') );

URL: https://www.barattalo.it/coding/two-post-types-share-the-same-taxonomy-in-wordpress/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.