rickdavidson
Member
Posted 3 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 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.
rickdavidson
Member
Posted 3 years ago #
Anyone? PHP geniuses? I'm sure this has been hit - and hopefully solved - before.. ?
rickdavidson
Member
Posted 3 years ago #
Hey thanks Filo, will try that out! Let you know...
rickdavidson
Member
Posted 3 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'); ?>
rickdavidson
Member
Posted 3 years ago #
Can anyone help with this? A lot of people seem to have the same problem...