Answer the question
In order to leave comments, you need to log in
How to display posts only child categories in wordpress?
Good evening. When switching to a parent category, its child subcategories are displayed, but posts of child categories are also displayed. How to display posts only in child categories, and remove them in the parent category. is it empty?
Answer the question
In order to leave comments, you need to log in
Approximately it is done like this:
Here https://codex.wordpress.org/The_Loop in the section "Multiple Loops Example 1" there is an example of solving your case:
// Get the last 10 posts in the special_cat category.
<?php query_posts( 'category_name=special_cat&posts_per_page=10' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<!-- Do special_cat stuff... -->
<?php endwhile; ?>
<?php
if ( is_home() ) {
query_posts( 'cat=-1,-2,-3' );
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question