WordPress: Prevent Showing of Sub Category Posts

Posted by Carlos Pattrezzi on Stack Overflow See other posts from Stack Overflow or by Carlos Pattrezzi
Published on 2010-05-29T02:24:48Z Indexed on 2010/05/29 2:32 UTC
Read the original article Hit count: 296

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about query

Related posts about Wordpress