I've got a publish list on my small home page that's exhibiting all posts in chronological order (DESC). I wish to exclude posts from the specific category out of this list. How do you build a storage shed? My totally...

<ul class="home-news"><?php
                        $args = array( 'numberposts' => 5, 'order'=> 'DESC', 'orderby' => 'post_date' );
                        $postslist = get_posts( $args );
                        foreach ($postslist as $post) :  setup_postdata($post); ?> 
                            <li>
                            <a href="<?php the_permalink() ?>">
                                <?php the_title(); ?>
                                <span>Posted on <?php the_date(); ?></span>  
                            </a>
                            </li>
                        <?php endforeach; ?>
                    </ul>

Solution 1

Add the next for your args array:

$args = array( 'category' => '-id', ...);

Where id may be the category id from the category you need to exclude. This solution won't diminish the amount of posts asked for.

Solution 2

Add the next at the outset of within the foreach loop:

<?php 
    $category = get_the_category();
    if ($category[0] -> cat_name == 'exclude_category_name') continue;
 ?>

Observe that if posts have multiple groups, you would loop with the $category array and appearance each element.