Querying taxonomy and cpt-onomy in one query
-
Hello!
I have two custom post types, Products, and FAQs. FAQs has a taxonomy named faq_categories, and it also uses Products as a CPT-onomy to link the two. So on an individual product page, I need to list the FAQs by faq_category and only if they are linked to that product. Here is the code I am trying, but it is not quite working:
<?php $myterms = get_terms('faq_categories', 'orderby=none&hide_empty'); $prodname = get_the_title(); $slug = $post->post_name; foreach ($myterms as $term) { ?> <li><a href="<?php echo $term->slug; ?>"><?php echo $term->name; ?></a> <ul> <?php $args = array( 'post_type' => 'faqs', 'faq_categories' => $term->name, 'tax_query' => array ( array ( 'taxonomy' => 'products', 'terms' => $slug, 'operator' => 'IN' ) ) ); query_posts($args); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li><?php the_title(); ?></li> <?php endwhile; endif; wp_reset_query(); ?> </ul> </li> <?php } ?>
Any help greatly appreciated ??
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Querying taxonomy and cpt-onomy in one query’ is closed to new replies.