we have a redirect function for a Custom Post Type to redirect single view pages for certain terms back to their archive landing page. There should only be single view pages for one specific taxonomy, all others only show snippets on the archive landing pages. But WP still creates the single pages for all created posts, and sometimes search engines find them, so we need to stop that.
Here's what we currently have, which DOES work for ONE of the taxonomy terms that should redirect. The problem now is that there are some posts that have NO terms assigned, and those need to redirect as well. Not sure how to target this.
If it's easier to target ALL instances EXCEPT the one term that does not redirect, that term is 'Team' (which just happens to be the same name as the post type).
if( is_singular( 'team' ) && has_term('support', 'team-area') ) {
wp_redirect( home_url('/who-we-are/'), 301 );
exit();
}
}
add_action( 'template_redirect', 'team_redirect' );