Excluding a category
-
I need to exclude a category (top stories, category 7) from showing up in the recent posts section below articles on my site. Here’s the code that brings in recent posts:
<?php $category = get_the_category(); $categories = array(); foreach($category as $x){ array_push($categories, $x->cat_ID); } $categories_join = implode(',',$categories); $exclude_post_id = $post->ID; $args = array('cat' => $categories_join, 'showposts' => $post_num, 'post__not_in' => array($exclude_post_id)); ?>
The category ID I want to exclude is 7. I can’t seem to make it work. Help!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Excluding a category’ is closed to new replies.