X

How to Exclude Specific Categories from Your Blog Homepage?

You may not like a specific category on your home page. Learn how to Exclude Specific Categories from Your Blog Homepage.

In WordPress, there are various tips and tricks to change the layout and appearance of your website/blog. WordPress comes loaded with plenty of themes and layouts which you can edit and customize as per your business requirements. When you display the latest posts on home page some users prefer to exclude certain categories which are displayed on their blog homepage. You can use a simple technique to achieve this option by editing the functions.php file and creating a filter in it. All you have to do is create a function for excluding some categories in the home page by writing a query. You can find the code snippet as below: 

function exclude_category_home( $query ) {

if ( $query->is_home ) {

$query->set( ‘cat’, ‘-6, -12’ );

}

return $query;

}

You can change the category IDs in the query to specific values based on which category you wish to exclude in your blog homepage. Once done you can save the file and add this filter to functions.php file as below:

add_filter( ‘pre_get_posts’, ‘exclude_category_home’ );

When you activate the function through WordPress dashboard and reload your website homepage, you will find that the categories blocked by you will not be displayed under home page. The WordPress dashboard has lot of options for manipulating the website and is similar to control panel found provided by web hosting services. You can modify the default themes by editing the style.css present in the WordPress themes directory.

One of the important advantages of using WordPress to design a website or blog is that it’s absolutely free and you will not be charged for web space or themes.  There are more than 210 default themes and it also allows you to create custom themes. It has various features like Social media integration, custom plugins, mobile platform support, multilingual supports, spam protection etc.

Categories: blogosphere
Prashant Sharma: <a title="About" href="http://www.techpluto.com/about-us/">Prashant Sharma</a> is a Delhi based Entrepreneur who spent most of his college days polishing his marketing skills and went for his first business venture at 19. Having tasted failure in his entrepreneurial debut, he turned a Tech-enthusiast, specializing in web technologies later. Join him on <a href="https://plus.google.com/110037121732872055442/?rel=author">Google Plus</a>
Related Post