What is “main query”? [duplicate]

Your filter has a bug in it, namely when you call is_main_query, you’re not checking if the passed query is the main query, your checking if the currently active query is the main query, which will always be true.

So instead try this:

add_action( 'pre_get_posts', 'some_name');
function some_name($query) {
    if ($query->is_front_page() && $query->is_main_query()) {
        $query->set( 'post_type', 'some_post_type' );
        return;
    }
}

Leave a Comment