Absolutely. Since you can instantiate to a variable a query you can do it as much times as you want. Of course query loops require a lot of connections to the database so you have to be careful. Very often if you need many subqueries it basically means that your workflow can be enhanced in some way.
Example of a subquery:
$some_posts = new WP_Query();
$some_posts->query('cat=1&showposts=2');
while ($some_posts->have_posts()) : $some_posts->the_post();
// Start new subquery with query values
$inner_query = new WP_Query();
$inner_query->query('cat=1&showposts=2');
while ($inner_query->have_posts()) : $inner_query->the_post();
// Do something in your inner/sub query
endwhile;
endwhile;
Related Posts:
- is_category() in pre_get_posts strange error
- Rearranging posts based on categories
- Custom Query to search through categories
- How to query all posts of a specific category, and any other category combination
- is_category in pre_get_posts results in php notices
- Query the Loop without breaking it
- How to Check if a Child Category is Being Queried
- How Do I Merge Categories With phpMyAdmin
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- If newest post of category is newest post in general, skip first post of category
- Disallow categories from this MySQL query
- Include posts from feature category in pre_get_posts
- How to display posts under a specific subcategory of a given category
- get_the_category and echo out link to child-most/deepest category
- query in category.php repeats itself
- Display posts separated by Category in Author’s page
- Category param redirect to post type archive
- How to get related tags based on a category?
- Show popular post by category code
- How to get latest posts from each category in regular order
- category pagination got broken suddenly
- How to query categories with Advanced Custom Fields?
- Where and when does WordPress invoke routes
- And/Or Category Query
- Exclude category from query
- Overriding default calendar to show posts from a category
- function query_posts disabling current_page_menu class
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Using in ‘category_name’ in ‘$query->set();’?
- custom query for both category and pages using global $wpdb;
- Get categories of queried posts
- Query from multiple category (and)
- How to display posts from specific category using get_option function?
- SQL query to get posts from multiple categories but not in a category
- Conditional category query breaking?
- How to filter post from categories only if the posts appears in one of them, not the other?
- Category name for all posts getting assigned to a single random post
- Show Posts via cat+cat in URL that are in both Categories doesn’t work
- List of post categories only associated to another custom taxonomy
- how tho change number of posts in loop from specific categories
- Get category from slug list
- Issue with WordPress category search
- Querying posts from two different categories while looping inside another loop
- how to get postmeta info based on multiple categories?
- Too many categories drastically slow down my website
- How to get posts from many categories using WP_Query
- show posts found in multiple categories via category_name query string?
- Match two taxonomies to display a specific content
- Category slug in in loop always the same?
- display certain category on custom template page
- Detecting top parent category fails on home page
- How to use Greek characters/letters in a query?
- Displaying posts by year
- wordpress category.php query for featured news item, broken pagination and repeating posts
- How to show posts of a specific category
- How to get parent and child sub category (Taxonomy) order to display
- What’s the URL for a category archive?
- how to use a different domain/subdomain for authors/catagories on single site?
- Category count inside the link
- Is there a way to have duplicate category slugs?
- Multiple level category drop-down
- how to show posts of category random by session
- Remove “Parent” Selection When Adding/Editing Categories?
- Show post only if match all categories
- How to get product count with respect to categories in WooComerce
- Password protect a specific category page/post
- Additional featured post on first page
- Displaying a full post instead of a slug per category?
- How do I toggle pagination on/off in search results and category listings via a link?
- How can I get categories IDs if multiple categories requested via URI?
- List categories with custom code
- How do I make the category sidebar widget (stock) display the total # of posts including those in subcategories?
- Can Categories be used to hack a Multisite-like setup w/ a single MySql db?
- Why do I have stray bullet from
- Custom loop of a single category, cannot order by date. What am I missing?
- Get URL Category Name By ID
- Show parent categories and sub categories but not grand children categories
- Why is my sub-category template showing the wrong posts
- Get 1st parent category id from post
- Natural sort / ordering wp_dropdown_categories
- Make wp_dropdown_categories into a variable that persists until changed?
- Best way to categorize/populate a magazine style layout
- Mass Update User Profile Checkbox Options
- Category sticky latest
- How to list posts from a sub-category that is listed in a parent category (more details below)?
- How to check parent & child category
- How do I merge WooCommerce categories with the same name?
- Custom get_the_password_form
- In ACF, how to show custom category selection tab upon selecting a main category
- WooCommerce – Get products from category right before deleting category
- omit categories from main navigation menu
- How to relocate images
- Category next page link not working
- Category archives
- Category For Pages In WordPress
- Inserting categories as a hierarchical terms from frontend form
- Adding a button to a product if it’s in a category, then linking to that category
- Using pagination with multiple loops causes it to break
- How can I show page per category in wordpress? (Yes, category by page!)
- Fetch all categories from database