0

From Archive Page I want to remove posts from couple of categories, as they have different style formats which will not look good with other category style formats.

1 Answer 1

1

try this...

Not Tested

add_action("pre_get_posts","my_category_remove");

function my_category_remove($query)
{

if(is_archive()) {
$query->set('category__not_in', array(/*the categories (ID's) you wish not to show, comma separated*/));
}

return $query;
}

Reference

3
  • By /*all the post ids*/ you meant /*the categories you wish not to show*/ ? Jul 15, 2013 at 10:03
  • Yes. You should provide ids of all the categories you want to escape. provide the ids separated by comma(,). Jul 15, 2013 at 10:05
  • FYI: When u visit the posts page in admin panel, you won't be able to see the posts from that category so please edit the condition as follows if ($query->is_archive && !is_admin()) {} Jul 15, 2013 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.