WP_Query with custom taxonomies and post types…!
-
Hi, so I’ve read up on this a lot, and I’m still having issues getting the data I need. Here’s the task…
I have 6 custom post types, they all share one taxonomy which has many terms. On my home page I need to get the top 4 most used/popular terms for each custom post type. I’ve discovered I might be able to do with with wp_query, a little like my code (which doesn’t work, it’s ignoring the taxonomy and calling all posts from the CPT);
$args = array( 'post_type' => 'pt_plumbers', 'tax_query'=>array( 'taxonomy'=>'trade', 'field'=>'slug', 'term'=>'boiler-installation' ) );
To fully make this work I think I will be using a second “hidden” taxonomy which is unique to each CPT, making the query feasible for each CPT (so I don’t just get the actual top 4 terms across the entire site, it must be post type specific).
Hope that makes sense, hit me with what you’ve got while I still have some hair ??
Thanks!
- The topic ‘WP_Query with custom taxonomies and post types…!’ is closed to new replies.