• 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 https://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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter rickdavidson

    (@rickdavidson)

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

    Check out this thread.

    Thread Starter rickdavidson

    (@rickdavidson)

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

    Thread Starter rickdavidson

    (@rickdavidson)

    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’); ?>

    Thread Starter rickdavidson

    (@rickdavidson)

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to? Display X posts without counting hidden category’ is closed to new replies.