[resolved] query filtered by category still gets the wanted number of posts (3 posts)

  1. Malaiac
    Posted 10 years ago #

    I want to display exactly the last four posts, excluding posts from 2 categories (and a "do not duplicate" post)

    So I wrote :

    <?php query_posts('showposts=4'); ?><br />
    <?php while (have_posts()) : the_post(); $do_not_duplicate = $post->ID; ?><br />
    <?php if ( in_category('5') ) continue; ?><br />
    <?php if ( in_category('2') ) continue; ?><br />
    <!-- do stuff --><br />
    <?php endwhile; ?>

    WP get the last four posts, and doesn't display the post from cat 5 & cat 2. Well, "it works".

    Problem is : if one or more posts from the last four is in cat 5 or 2, it doesn't display.
    So I may have 0, 1, 2, 3 or 4 posts displaying (if 4, 3, 2, 1 or 0 posts from last four is in cat 5 / 2).

    How can I "solve" this, and be sure to have four posts displayed ?

  2. Nicki Faulk
    Posted 10 years ago #

    I may have a solution ... I did something similar for a client's blog using the Customizable Post Listings (aka "Recent Posts") plugin by Scott Reilly.


    However, I don't know how 2.0 friendly it is. (My client is running a highly customized version of 1.5 which is on a private network, so he saw no need to update.)

  3. Malaiac
    Posted 10 years ago #

    I use C2C Customizable for other stuff, how can I forgot it could display post content ? Thx

Topic Closed

This topic has been closed to new replies.

About this Topic