How to Exclude Category From Blog Page

From this tutorial you’ll learn how to exclude category from Blog page and to hide the whole category of posts from being viewed.

Excluding 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 in order to make changes in it.
  • 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). Exclude Category
  • 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).

If you want to exclude several categories, you need to learn the ID numbers of both of them and separate them with commas inside the code.

  • 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.
On-page SEO optimization