How to exclude / hide posts of a category (or multiple categories) from displaying in the blog homepage?

Suppose you have a blog on WordPress setup and customization, and you want to hide “Books Review” and “Hosting Review” from blog homepage(is_home). Because you want to place them in the navigation menu.

So here is an easy tutorial at your service.

  • You have to find the category id for each categories. You can find them from Dashboard > Posts > Categories, click on Edit and take a note of the number beside tag_ID=. Repeat the step if you want to exclude multiple categories.
  • Now open functions.php file from WordPress theme folder. If you are using our basic WordPress child theme, you may have to create a file called functions.php.
  • Paste the following code in the file.
function exclude_category( $query ) {
    if ( $query->is_home ) {
        $query->set( 'cat', '-15,-48' );
add_action( 'pre_get_posts', 'exclude_category' );
  • Number represents the category id. Suppose your Book Review category id is 15 and Hosting Review category id is 48. If you have multiple category, add a minus (-) before your category id and add them with a comma (,) separators as we did.
  • Now save the file and upload to your theme folder.
  • Refresh your homepage. I believe you have successfully excluded all posts of a category (or multiple categories) from your homepage.

Request for this article came from one of our readers via Ask for Help section. If you want some help, why don’t you leave a comment or ask for professional WordPress help and our team will contact you shortly.

Jinnat Ul Hasan

By | On Wednesday, August 24th, 2011 | Under How To's | No Comments ยป


Contact our experts, most of the time we assist our readers free of charge.

Those who found this page were searching for:

  • exclude multiple categories wordpress from blog
  • How to hide "leave a comment" on wordpress
  • wordpress function to hide category from blog
  • wordpress hide category functions.php
  • how to exclude post from category in wordpress
  • hide posts in category from blog wordpress
  • multiple category posts
  • hide posts categories home page
  • exclude posts in category from sitemap
  • wordpress rss how to exclude categories

Previous post:

Next post: