Exclude a Category From Front Page

Go to Appearance > Editor, and open functions.php.
Add the function which is given below :

function exclude_category($query) {
if ( $query->is_home ) {
$query->set('cat', '-CATEGORY ID');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

where CATEGORY ID is written put the number of your category.To exclude more category just add category id separated by a ‘ , ‘ Don’t forget the minus sign in front of it. Save it, and you’re done.

Share on TumblrShare via email

1,376 views


Leave a Reply

xD ^_^ >_< ;) :| :x :love: :cry: :P :D :?: :/ :-o :) :( :$ 8)