The reason for that is pretty straight forward…
In you code (at least in the part you’ve showed) the only condition you check is:
if ( is_post_type_archive( 'people' ) )
So when you’re on archive for people, this condition will be true for every WP_Query on that page.
Let’s say you have some “Latest news” section in the footer and they’re retrieved with WP_Query. pre_get_post
filter will get run for such WP_Query too and the condition above will be still true.
And menu is another example, because it’s also retrieved using WP_Query…
That’s why it’s important to check if $query->is_main_query()
also, if you want to modify only the main query.
So your code should look something like this:
else if ( $query->is_main_query() && is_post_type_archive( 'people' ) ) {
$query->set( 'orderby', 'meta_value' );
// Bug: Line below causes the menu not to show.
$query->set( 'meta_key', 'display_order' );
$query->set( 'order', 'ASC' );
}
PS. Of course there is possibility that the same should be applied for other parts of that if statement, so the structure of that if may get changed…