Setup proper 301 redirect for deleted tags

Sounds like an easy task to do. I think hooking into ‘template_redirect’ and conditionally triggering redirect is the way to go.

EDIT: Seems is_tag() isn’t reliable once 404 is triggered. That’s why we need to look into the query vars to figure out if it’s really a tag query or not.

function redirect_404_tags_wpse67077() {
    global $wp;
    if ( ! empty( $wp->query_vars['tag'] ) && is_404() ) {
        wp_safe_redirect( home_url("https://wordpress.stackexchange.com/"), 301 );
        exit;
    }
}

add_action( 'template_redirect', 'redirect_404_tags_wpse67077', 1 );