Redirect taxonomy to custom template to list terms in taxonomy

The 404 might be created because your regular expression requires the value after ‘state/’. Please try to replace:

function handle_taxonomy_route()
{
    add_rewrite_rule('^state/([^/]+)/?', 'index.php?state_var=$matches[1]', 'top');
}

with:

function handle_taxonomy_route()
{
    add_rewrite_rule('^state/([^/]*)/?', 'index.php?state_var=$matches[1]', 'top');
}

Leave a Comment