Last query_var not working with rewritten URL

[] = not [] .= to append to an array.

function custom_query_vars_filter($vars) {
  $vars[] = 'ae_issues';
  $vars[] = 'issueloc';
  $vars[] = 'issuearea';
  return $vars;
}

Another trick, if you don’t want to mess with a query is to change these vars to something like _issueloc & _issuearea. I found making custom queries as flags is nice for template redirects but not necessary to mess with the main query (unless you require it).


WORKING

An alternate might be to added using add_rewrite_tag().

add_action( 'init', function() {
    add_rewrite_tag( '%ae_issues%', '([^/]+)' );
    add_rewrite_tag( '%issueloc%', '([^/]+)' );
    add_rewrite_tag( '%issuearea%', '([^/]+)' );

    add_rewrite_rule( '^issues/([^/]+)/([^/]+)/([^/]*)', 'index.php?ae_issues=$matches[1]&issueloc=$matches[2]&issuearea=$matches[3]', 'top' );
    add_rewrite_rule( '^issues/([^/]+)/([^/]+)', 'index.php?ae_issues=$matches[1]&issueloc=$matches[2]', 'top' );
} );

add_filter('template_include', function($template){

    global $wp_query;
    if( isset($wp_query->query_vars['ae_issues'])) {
        echo "<pre>";
        print_r($wp_query->query_vars);
        wp_die();
    }
    return $template;

});