• Hey there,

    I have a specific categories displaying in my sidebar depending on what page you are on. I have a separate list that displays subcategories and their posts. However, the loop that I am using to display the parent categories posts is also displaying the posts from my subcategories. I would like to remove subcategory posts from this list.

    Here is what I am currently using that is displaying the parent category posts as well as the child posts. How can I exclude child posts from this list?

    I DO NOT want to use a plugin and/or widget.

    <ul class="categoriesPost">
    	   <?php
          $catposts = get_posts('numberposts=100S&category_name=Photography');
          foreach($catposts as $post) :
       ?>
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
       <?php endforeach; ?>
       </ul>

    Any ideas?

The topic ‘Exclude category child posts from list’ is closed to new replies.