Filtering the main loop, not the sidebar
-
Hi!
I’m using the following code to prevent posts in specific categories from appearing on front page:
function front_page_excludes($query) { if($query->is_front_page) { $query->set( 'category__not_in', array(1,2) ); } return $query; } add_filter('pre_get_posts', 'front_page_excludes');
There’s a problem with this code, though. It’s affecting the recent posts widget on the sidebar, too, and I just want it to filter just the main loop, not the sidebar.
Any ideas?
Thanks in advance
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Filtering the main loop, not the sidebar’ is closed to new replies.