function exclude_category() { if ( is_home() ) { set_query_var(‘cat’, ‘-2′); } } add_filter(‘pre_get_posts’, ‘exclude_category’); ?> function exclude_category() { if ( is_home() ) { } } add_filter(‘pre_get_posts’, ‘exclude_category’); ?> As a blogger, there are instances where you do not want to showcase some particular categories on the menu bar of your WordPress blog. WordPress by default does not give you an option to chose the categories that you would like to publish (atleast till the time this blog post was written). A simple hack into the functions.php file of your theme would easily allow you to achieve this, just follow the instructions below:
set_query_var('cat', '-2, -5, -7');
0 comments:
Post a Comment