Ready to get started?Download WordPress


Filtering the main loop, not the sidebar (2 posts)

  1. leemon
    Posted 4 years ago #


    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) {
    	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

  2. esmi
    Forum Moderator
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic