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 besidetag_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.
1 2 3 4 5 6 |
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
DO YOU NEED OUR HELP?
Contact our experts, most of the time we assist our readers free of charge.Those who found this page were searching for:
- how to exclude child category in blog post
- exclude category twentyeleven
- wordpress exclude post child category
- hide post on homepage in blogger
- multiple categories post homepage wordpress
- how do you hide this post multiple
- wordpress exclude post with multiple categories
- hide posts in category from blog wordpress
- hide category posts on homepage
- exclude categories from display on blog