I’ve been circling this drain for years trying to make things just right.
Third verse, almost the same as the first.
request data means that requests that end up with a 404 or are a search produce weird results with navigation menus, among other oddities. So I’m back to using
pre_get_posts to include custom post types, with a few refinements.