WordPress: Prevent Showing of Sub Category Posts
- by Carlos Pattrezzi
Hi,
I'd like to know how to prevent showing of sub-category posts. My home page lists all posts from three "main categories" (parent category), but unfortunately it's also listing some posts from the sub-categories.
Here's the code that I'm using to get the posts from specific category:
<h2>Category Name</h2>
<ul>
<?php $category_query = new WP_Query(array('category_name' => 'category1', 'showposts' => 5)); ?>
<?php while ($profissionais_query->have_posts()) : $profissionais_query->the_post(); ?>
<li>
<a class="title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
</li>
<?php endwhile; ?>
</ul>
Does anyone have an idea?
Thank you.