I have created a custom post type named "my-products" and registered custom taxonomy "my-products-categories"
Then I created some Categories like "Webdesign", "Print", "Logo"
I need to display all the posts divided in their categories inside jQuery Tabs. So you could think about it like in the first Tab I have the posts from the Category "Webdesign" and possible sub-categories, in the second Tab all the posts from "Print" and possible sub-categories etc.
Here is my approach:
function displayCustomPosts() {
$the_query = new WP_Query(array( 'post_type' => 'my-products')); ?>
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
jQuery Tabs with the posts
endwhile;
endif;
}
What my problem is is that I dont want to use multiple WP_Query to query the different categories and display them separately but to only use WP_Query once and filter the categories afterwards. That would be better for the performance I think!?
So is there a way to do that with WP_Query like first query all posts from every category and then when displaying the content of those posts filter them by their categories.
Or would I need to use multiple queries to achieve what I want?