Pre_get_posts Affecting Sober Controller

If I add a filter like this:

function custom_query( $query ) {
    if ( is_admin() ) {
    if ( $query->is_archive('geo-schools') && $query->is_main_query() ) {
        $query->set( 'post_type', array( 'schools') );
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );
add_filter( 'pre_get_posts', 'custom_query' );

I get the expected result with the appropriate post type in the archive template, although the Sober Controller no longer passes data appropriately. For instance, GeoSchools.php will no longer pass the correct data. On top of that

Any help would be appreciated.

This topic was automatically closed after 42 days. New replies are no longer allowed.