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:

  • Leave a Comment site:
  • how to hide number beside categories wordpress
  • posts from one category do not display
  • hide post category
  • hide post of specific category from post page ...
  • exclude post wordpress
  • how to hide posts from a category on homepage
  • wordpress twenty eleven exclude posts from blog
  • hide category from homepage wordpress
  • excluding+post+by+tag_ID+in+wordpress

Previous post:

Next post: