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.


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;


| improve this answer | |
  • By /*all the post ids*/ you meant /*the categories you wish not to show*/ ? – Mike Madern Jul 15 '13 at 10:03
  • Yes. You should provide ids of all the categories you want to escape. provide the ids separated by comma(,). – Rohit Pande Jul 15 '13 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()) {} – Rohit Pande Jul 15 '13 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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