WordPress.org

Ready to get started?Download WordPress

Forums

Display posts from a specific range of categories (2 posts)

  1. Jason_K70
    Member
    Posted 1 year ago #

    Hi,

    I realise this has been addressed several times in the forums, but I've not been able to relate the solutions to the code that I'm using.

    I've had a site built for me, I have a "latest news" area, which currently shows all posts, regardless of category. I need to show only posts from a specific range of categories (or even just exclude one particular category from being displayed). The code is currently as follows:

    <?php
    $args = array('post_type' => 'post', 'posts_per_page' => 3);
    $loop = new WP_Query($args);
    $count = 0;
    while ($loop->have_posts()) : $loop->the_post(); $count++;
    ?>

    It then goes on to print the titles and excerpts, etc. for posts from all categories. So what I'd like to do is either display posts from just categories 1, 2 and 4, or exclude posts from category 3.

    Any help would be hugely appreciated.
    Jason

  2. esmi
    Forum Moderator
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic