I don’t want my posts from categories “Softwares” and “Wishlist” to appear in the main thread of my blog. In the past, I had to add some code in the “functions.php” page of my theme (twentyeleven) to filter that posts from the home page. Now, I am using the plugin “WP Exclude From Homepage 1.1.2”.
Click to Read More
The code I used to add in \\<YourSynology>\web\wordpress\wp-content\themes\<YourTheme>\function.php was:
[code language=”php”]/**
* Excludes post in category "softwares" from the home page
*/
function exclude_cat_from_home($query) {
if ( $query->is_home) {
$acats = array();
foreach ( array(‘wishlist’,’softwares’) as $catName ) {
$cat = get_category_by_slug( $catName );
$acats[] = ‘-‘.$cat->cat_ID;
}
$cats = join(‘,’, $acats);
$query-> set(‘cat’,$cats);
}
return $query;
}
add_filter(‘pre_get_posts’,’exclude_cat_from_home’);
It was located at the very bottom of the file
Leave a Reply