Exclude Categories from the archive pages


/ Published in: PHP
Save to your folder(s)

the numbers 108 and 18 are the category ids i wanted to exclude


Copy this code and paste it in your HTML
  1. add_action('pre_get_posts', 'gloss_remove_glossary_cat' );
  2.  
  3. function gloss_remove_glossary_cat( $notused )
  4. {
  5. global $wp_query;
  6. global $gloss_category;
  7.  
  8. // Figure out if we need to exclude glossary - exclude from
  9. // archives (except category archives), feeds, and home page
  10. if( ( is_archive() )) {
  11. $wp_query->query_vars['cat'] = '-108,-18' . $gloss_category;
  12. }
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.