[] =
不[] .=
附加到数组。
function custom_query_vars_filter($vars) {
$vars[] = \'ae_issues\';
$vars[] = \'issueloc\';
$vars[] = \'issuearea\';
return $vars;
}
另一个技巧是,如果不想弄乱查询,可以将这些变量更改为
_issueloc
&;
_issuearea
. 我发现将自定义查询作为标志对于模板重定向来说很好,但不必处理主查询(除非您需要)。
工作时,可以使用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;
});