One of the great things about Wordpress is that it is an excellent tool for blogging. If you visit your blog page, you'll see that, the Wordpress Loop will automatically list recent posts from all your categories.However sometimes you might not want a certain category to show up in the list of posts. This is where the "pre_get_posts" action is so useful. Perhaps you are using a particular category of posts for your image slider, and so you don't want them to show up in the main page. Simply add the following code into your childtheme's function.php file and replace with the IDs for the category you want to hide.Note: This will hide that category from both your blog page and also from your RSS feed. (replace '13' with your category ID)[php]/** Remove category from feed and blog page */function dtwd_exclude_category($query) { if ( $query->is_feed || $query->is_home ) { $query->set('category__not_in', '13' ); } return $query;}add_filter('pre_get_posts', 'dtwd_exclude_category');[/php]

Comments: