Adding Custom Post Types to category/tag/author archives breaks header content

The amazing @Krzysiek Dróżdż was right on the money on this one!

I can’t believe nobody has picked it up until now.

The code I was using has been shared on all sorts of well-known/well-referenced sites, as is, and NOBODY has fixed it to include is_main_query.

Revised code, for anybody else who’s searching:

// Add New Custom Post Types to Archives

function rtt_add_cpts_to_archives( $query ) {

    if( $query->is_main_query() && is_category() || is_tag() || is_author() && empty( $query->query_vars['suppress_filters'] ) ) {

        $query->set( 'post_type', array( 'post', 'nav_menu_item', 'work', 'event', 'news', 'newsletter' ) );

        return $query;

    }

}

add_filter( 'pre_get_posts', 'rtt_add_cpts_to_archives' );