Exclude category with add_filter(‘pre_get_posts’
-
function exclude_category($query) { if ($query->is_home) { $query->set('cat', '-7,-67,-6'); } return $query; } add_filter('pre_get_posts', 'exclude_category');Hi I found this to exclude categories on my index page (home). it works a little bit to good…
It affects also my 2 sidebars.
I make the calls in the sidebars withquery_posts('showposts=30&cat=7,-6');How can i make this affectr only my main ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Exclude category with add_filter(‘pre_get_posts’’ is closed to new replies.