• Hi all,
    I need to list all my post-types that has the same taxonomies as post.
    I cant figure out how to do it. The thing is that I have multiple taxonomies too in each post but I can’t get them.

    $terms = get_the_terms( $post->ID, $taxonomy_slug);
    $term_ids = wp_list_pluck($terms,'term_id');
    
    $second_query = new WP_Query( array(
    'post_type' => array ('p-livros', 'p-cinema', 'p-games'),
    'tax_query' => array('relation' => 'OR',
    	array(
     	'taxonomy' => 't-interacao',
    	 'field' => 'id',
     	'terms' => $term_ids,
    	  ),
    
    	 array(
    	 'taxonomy' => 't-arte',
    	 'field' => 'id',
     	'terms' => $term_ids,
     	),
    
     array(
     'taxonomy' => 't-editoriais',
     'field' => 'id',
     'terms' => $term_ids,
         )),
    
    'posts_per_page' => 10,
    'ignore_sticky_posts' => 1,
    'orderby' => 'rand',
    'post__not_in'=>array($post->ID)
     ) );
    
    if($second_query->have_posts()) { while ($second_query->have_posts() ) : $second_query->the_post(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Multiple Post Type Multiple Taxonomies inside Loop’ is closed to new replies.