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


try this...

Not Tested


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;


  • By /*all the post ids*/ you meant /*the categories you wish not to show*/ ? Commented 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(,). Commented 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()) {} Commented Jul 15, 2013 at 10:13

Your Answer

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

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