One possibility:
<?php
$sub_cats = get_categories('parent=" . get_query_var("cat'));
if( $sub_cats ) :
foreach( $sub_cats as $sub_cat ) :
$sub_query = new WP_Query( array(
'category__in' => array( $sub_cat->term_id ),
'posts_per_page' => -1)
);
if ( $sub_query->have_posts() ) :
while( $sub_query->have_posts() ) : $sub_query->the_post();
//your output//
endwhile;
endif;
endforeach;
endif;
?>
http://codex.wordpress.org/Function_Reference/get_categories
http://codex.wordpress.org/Class_Reference/WP_Query
Related Posts:
- Is There a Difference Between Taxonomies and Categories?
- WooCommerce: List All Categories
- Get rid of WordPress category, tag and author archives?
- Filtering categories in the permalink structure
- Wrap Post count in a span
- wp_nav_menu not appearing for a couple pages
- Why aren’t sub-categories nested after creating post in the WP Admin?
- Preventing index.php?category_name=something from redirecting
- How to get category id of current post?
- Programmatically create product category and add thumbnail in woocommerce
- Trash bin for categories
- Categories’ hierarchy in URL
- Display one category in one page
- How to get next previous category in same taxonomy?
- is_archive() content being shown instead of is_category()
- Check is category parent or not from its ID
- If a post has two categories with different permissions, what will happen? [closed]
- Dropdown category filter
- Filter out posts before display category count
- Category page shows Oops! That page can’t be found
- How to show in search results posts with a particular tag in a particular category?
- Category vs Tag vs Table
- How to find the number of Tags a post has?
- Multiple menu items highlighted
- How can I enable a TINYMCE rich text editor in the admin interface?
- Add title, post content, and category like add_post_meta and update_post_meta
- wordpress wp_list_categories
- How to create button to direct to certain category
- Highlight wp_nav_menu when category is selected
- How to make 2 tag feeds show up on 1 page?
- Best way of getting WooCommerce category path
- Display the last post by each category?
- Get link which associated with a specific category and tag
- How to disable default category linkbuilding?
- Order categories by name or view count
- How to assign posts without any category to the default category
- Show only first category name in RSS?
- Show parent category in URL of subcategory archive page
- Filter $cpt categories to omit certain category
- Yearly Archive for Categories with dropdown
- get_categories listing foreach with children
- Create category post shortcode
- Undefined property: stdClass::$id when retriving term ID
- Wacky taxonomy in wordpress
- Link to the next/prev posts in index loop in same category?
- Output the text before category
- Change div background acording to the selected category
- Why title_li =” not working
- Wrong category nice name is displayed on archive page
- Custom Permalink with child categories creating 404
- Cannot filter categories by parent category
- Redirect year month day postname permalink structure to category postname structure
- Show all sub categories?
- Category nicename inside loop in wordpress
- Exclude all subcategories in the_category (post)
- Generating a feed of all but one category of posts
- Displaying another main nav menu for specific category
- Exclude categories from list (wp_list_categories)
- How to display the 5 latest post titles but allow only 1 in there of a specific category
- WordPress: Using the category slug get the category ID using mysql query
- Create a Category with a front-end post
- How to add categories using mysql
- Posts made to category don’t show up (do show up on frontpage)
- Exclude category to “the_breadcrumb” functions
- How to fix select filter on category
- wp_dropdown_categories() works correctly but the list is not filtered in admin for custom post type. What is the problem?
- Migrate the posts of a category to another blog as a custom taxonomy
- Woocommerce only display child category when parent is checked (on add new product page)
- Add $args to wp_list_categories
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- Show parent category wp_list_categories wordpress
- Taxonomy custom check box meta field not getting saved
- Check with Jquery if second level checkbox from categories are checked
- In if…else condition, the else statement shows even if if statement is correct
- How to show entries related to main category
- Restrict retrieved terms by category?
- Get category from slug list
- When category name and title are the same … WP will select archive.php instead of single.php
- Re-coding category-template.php to go to custom URL
- Category removal – Portfolio Category:
- How to Change Sort Order of default WordPress Catgory Widgets?
- Show One Level Category id
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- Custom filters inside a specific category?
- $args Orderby The number
- Most efficient way to have 1 template for parent, 1 template for child categories?
- Function to list posts from current post’s category fails in WP 3.8
- Multiple parent categories
- Custom fields setup when category selected filter subcategories
- Formating content in category.php
- How to use Greek characters/letters in a query?
- Getting categories to change appropriately when using $cat = ‘ ‘;
- how to call the category of the post
- Category related -> excerpt, title and thumb in sidebar on article page
- How to have a category not show up in query post with page panigation?
- why is the delete option missing from just one category?
- Get all categories
- Show category post order ASC
- How to display all category images for single post in a page?
- sub-category showing up in wrong order in breadcrumbs