Welcome friends! By default, WordPress displays posts from all categories on the home page. Sometimes it’s not appropriate. Especially, the problem arises when some categories of the blog are not desirable to display in the general cycle of WordPress, like on the main page of a blog. There are many reasons for this. For example, the sale of advertising in posts of this category, or the non-topic nature of this category for a blog. Thanks to a small addition to the functions.php file of your WordPress theme, you can exclude category from blog page.
So, in order to do this, you need to know the ID of a specific page. Down the necessary (or rather unnecessary to display) category IDs and exclude them from displaying on the main page. And a little below, we’ll show you how. Be attentive to details!
Easy Steps to Exclude Category from Blog Page
- First, let’s log in to WordPress Dashboard using your login credentials. Then open Appearance >Editor tab on the left of the Dashboard to access your theme editor.
- Select the theme you’re using from the dropdown menu and locate functions.php file to exclude category from blog page.
- Before you start to apply changes to the file you have to learn the category ID number. To do it navigate to Posts > Categories tab and hover on the title of the category you want to exclude. You’ll see the ID number at the bottom left corner inside the link (it is a part of it).
- Now you should add the following lines of code at the very end of the file. Don’t forget to replace the ID number in the code with the actual ID number of the category you need to remove (in our example the ID number is “1”, “-“ tells us that the category should be excluded).
- Now click on Update button at the bottom of the Editor page. As a result, you won’t see the excluded category on the Posts page anymore.
Wrapping It Up
Our desires are unpredictable and sometimes it happens that the blog page should be turned a bit into the new design. In this tutorial, we’ve told you how to exclude category from blog page on WordPress. You’ve also discovered how to hide the whole category of posts from viewing. As you can see the steps are extremely easy and don’t demand any extra skills.
So, using WordPress hide category on the whole page or just post. Only a few mouse clicks and hocus-pocus is on board. Enjoy the handiness of WordPress!