Sometimes you may need to hide certain categories from your WordPress Blog. Currently there is no in-built facility available in WordPress to hide categories though there are many themes available to with this functionality. If your WordPress theme does not have this option, you will require making following changes to hide categories from your blog home page.
[1] Obtain category ID:
To obtain category ID, login to your WordPress admin and go to Posts > Categories. Click on the category name which you want to exclude from Home page. Copy the value of cat_ID from the URL.
categories.php?action=edit&cat_ID=XX
XX is your category ID.
[2]Add required code in theme’s functions.php:
Now, go to Appearance > Editor and open functions.php. Add the following function at the bottom:
function exclude_category($query) {
if ( $query->is_home ) {
$query->set('cat', '-xx');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');
The above code must be written within php tag.
If you want to block multiple categories, use the following condition:
$query->set('cat', '-1 -2 -3 -4 -5');
Popularity: 26%
WordPress Premium Themes
Categories
Tags
Web Hosting Discussion
- AccuWebHosting.com Joins Hands With SmarterTools, Inc.
- Munin MySQL monitoring graph is not updating or blank
- How to get more Twitter Followers
- LovingTech forum for Sale – BIG PROFITS TO BE MADE
- Unlimited Disk Space and Unlimited Bandwidth hosting – is this scam?
- How to reset Joomla administrator password
- How to reset vBulletin administrator password
Affiliate Programs
- 1BodyCare Affiliate Program
- ElegantThemes Affiliate Program
- Templatic.com Affiliate Program – Premium WordPress Themes provider
- PayPal Affiliate Program
- wpremix affiliate program – WordPress Premium themes provider
- Web Hosting Affiliate – DedicatedNOW Affiliate Program
- WooThemes Affiliate Program










