W3 Mind Logo
Home » How to exclude specific blog categories from blog archive page

How to exclude specific blog categories from blog archive page

Hey Friends,
If you want to remove or hide any specific blog categories from the blog archive page in WordPress. So you just need to add the below function or hook in functions.php file in your theme folder.

				
					function exclude_category( $query ) {
   if ( $query->is_home() && $query->is_main_query() ) {
   $query->set( 'cat', '-1, -2' ); //The IDs of the categories to exclude.
   }
   }
   add_action( 'pre_get_posts', 'exclude_category' );
				
			
About Author
Picture of W3Mind

W3Mind

W3Mind focuses on Blogging, Make Money Online, SEO, Business Blogging, Social Media, WordPress, Internet Tools, Web Design and Development.
Give it a Share
Facebook
Twitter
LinkedIn
You May Also Like
How to
START A
BLOG
(step by step)
Load WordPress Sites in as fast as 37ms!