Ready to get started?Download WordPress


How to? Display X posts without counting hidden category (6 posts)

  1. rickdavidson
    Posted 8 years ago #

    Hmm help. I have a category excluded from the loop (WP 2.0) using:

    <?php if (in_category('10')) continue; ?>

    but I'm only displaying 1 post. So.. the loop skips past - but still counts - posts in the hidden category and .. blank. Can see the problem at http://www.rickdavidson.com. Is it possible at all to tweak the code to move to the next post rather than loop around and still count the post? Is the above line just wrong? I can't use plugins etc to exclude the post from the index because I do display this category separately on the page. Hmm.

  2. rickdavidson
    Posted 8 years ago #

    Anyone? PHP geniuses? I'm sure this has been hit - and hopefully solved - before.. ?

  3. Austin Matzko
    Posted 8 years ago #

    Check out this thread.

  4. rickdavidson
    Posted 8 years ago #

    Hey thanks Filo, will try that out! Let you know...

  5. rickdavidson
    Posted 8 years ago #

    Hey, sorry I'm a php beginner. Grabbed the code from that other post, does this function go inside the loop or before? I've tried playing around but it just seems to repeat the last post. And is it possible to add more than one category?

    <?php function modify_where_clause($where) {
    global $wp_query, $wpdb;
    if ($wp_query->is_home && !strstr($where,'category_id'))
    $where .= " AND ID NOT IN (SELECT post_id FROM $wpdb->post2cat WHERE category_id=10)";
    return $where;
    add_filter('posts_where','modify_where_clause'); ?>

  6. rickdavidson
    Posted 8 years ago #

    Can anyone help with this? A lot of people seem to have the same problem...

Topic Closed

This topic has been closed to new replies.

About this Topic