You’ll have to get the child or parent categories yourself and pass all the IDs as an array via the category__in
argument of WP_Query. You can use get_ancestors
to get the top parent category, and get all child categories of that parent via the child_of
argument of get_categories
.
Related Posts:
- Display one latest post from multiple categories
- Enter a variable in the ‘category_name’ parameter
- Multiple Loops on category.php with pagination on last loop
- Pagination on category.php and tag.php not working
- category__not_in and id values from variable
- More efficient way to list posts by category [duplicate]
- Show multiple categories in query using redux framework variable
- multiple values in an array for category__and does not work with WP_Query
- the_category() doesn’t working in wp_query loop
- WordPress Numeric Pagination with Query String [duplicate]
- Printing direct descendants of a category with WP_Query
- Custom Category Page Not Working [duplicate]
- How do i add custom post types to this query?
- Should category.php and The Loop be used if the query needs to be customizable?
- Inject post (from specific category) between posts in Loop
- Exclude the category from the WordPress loop
- Exclude categories from search query
- get_field not displaying my custom field value
- Show div only if post is in specific category
- How to show a category post to a specific registered user
- Loop with Dynamic Categories
- How can I create a loop to build slides based on multiple categories using Coda Slider
- Custom query with category exclusion and post-meta “whitelist”
- Categories list loop – add separator every year
- How would you create a “weekly” archive?
- Exclude most recent posts from specific category in wp_query()
- How to exclude categories from recent posts, recent comments & category widgets?
- Listing all posts from current category on page
- Query Custom Post by Category
- How to query posts from specific authors and categories using WP_query?
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- How to show in search results posts with a particular tag in a particular category?
- List Posts by Category for a Non-Zero, Non-NULL Custom Field Value?
- Class active for Archive link – looped out
- Taxonomy name repeating when showing 2 posts from each category
- Display the last post by each category?
- Counter in loop in foreach
- Order by category titles
- ajax for filtering posts by category in wordpress loops
- Inside a loop, how to change CSS class based on category name?
- Limit get_categories to show each category once
- Is there a reason I cannot get the current category in a loop?
- Category archive is displaying all posts rather than the specific category
- Display posts from a category
- How to add orderby parameter for sorting on category.php
- wp_query is showing posts from other categories
- How to display the parent category if only the child category has been chosen
- Allow user to select categories that will display in post loop
- Do not duplicate posts with multiple categories in multiple loops
- Remove any product that is featured from regular display loop [WooCommerce]
- Two Sections on Woocommerce Catergory Page [closed]
- Getting the Most Recent Posts from Multiple Categories
- Display subcategories in dropdown
- Display category title and three latest post inside the category
- Query posts by views on category page
- Category nicename inside loop in wordpress
- filter a loop base on specific category
- Are term_taxonomy_id and term_id the same? [duplicate]
- Using in ‘category_name’ in ‘$query->set();’?
- Custom Page Template Category loop not functioning correctly
- Limit Loop to One Category
- Filter Category Loop Dynamically
- How can I use AJAX with check-box categories?
- Select posts that match multiple category names, must match all categories listed
- Conditional category query breaking?
- Problem: retrieving parent category’s first post
- How to display the 5 latest post titles but allow only 1 in there of a specific category
- Posts made to category don’t show up (do show up on frontpage)
- Category name for all posts getting assigned to a single random post
- Category post count is not correct
- Display all categories but only if they have posts in them that have a specific tag assigned
- Include last post date in get_categories loop
- How to get specific (grand parent) category of current post?
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Custom Loop with certain number of one category
- how tho change number of posts in loop from specific categories
- Template category.php with page (no posts)
- Get categories within specific term
- error in specific category loop
- loop in single.php of the same category
- Hide a category/posts from the homepage in wp
- Display 3 levels of categories on page
- Trying to display all posts in a category
- Display Taxonomies in loop with template args
- Custom Post Type + Category archive
- How to exclude a specific categogy from a custom page template
- Unable to get all tags from specific categories
- $args Orderby The number
- Querying Multiple Categories With Different Offsets
- How to get multiple loop in category.php, my scripts becomes madness
- My Query is getting the wrong data
- WP_query exclude a category unless it has more than one catagory
- Show only one category in main query, issues on tag page
- Custom loop by url
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- Do not show all post from all categories, just show posts from category in current loop
- IF have_posts contains posts from a certain category
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Echo Category In Loop
- Trying to WP_Query a category