WordPress Alternating main loop (pre_get_posts filter) Show posts from only one category


Example

add_action( 'pre_get_posts', 'single_category' );

function single_category( $query ) {
    if( !$query->is_main_query() || is_admin() ) return;

    $query->set( 'cat', '1' );
    return;
}