WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a category structure like following:


(B is sub category of A and C is sub category of B)

I have content only for category "C" and if I open Category "B" the content of category "C" is displayed. How can I prevent this? I want to display "No Posts" if I open Category "B".

share|improve this question
Can you post some of your code? It will help get to the answer – Mridul Aggarwal Jan 29 '13 at 11:11
@MridulAggarwal his code doesn't matter, he has asked general question – Eugene Manuilov Jan 29 '13 at 11:55
Then i understood it wrong. My Bad – Mridul Aggarwal Jan 29 '13 at 12:26

Assuming the context here is filtering out posts from category C when viewing the category B posts archive, you could accomplish this by using the query_posts keyword category__in (which does not include posts from child categories) instead of cat (which does include posts from child categories). Just add it in archive.php or category.php depending on what's appropriate for you theme.

global $wp_query;
$args = array_merge( $wp_query->query, array(
    'category__in' => get_query_var('cat')
query_posts( $args );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.