您可以这样做:
//add movies_view to query vars
add_filter(\'query_vars\', \'my_query_vars\');
function my_query_vars($vars) {
// add movies_view to the valid list of variables
$new_vars = array(\'movies_view\');
$vars = $new_vars + $vars;
return $vars;
}
然后基于该查询变量添加模板重定向:
add_action("template_redirect", \'my_template_redirect\');
// Template selection
function my_template_redirect()
{
global $wp;
global $wp_query;
if ($wp->query_vars["post_type"] == "movies")
{
// Let\'s look for the property.php template file in the current theme
if (array_key_exists(\'movies_view\', $wp->query_vars) && $wp->query_vars[\'movies_view\'] == \'overview\'){
include(TEMPLATEPATH . \'/single-movies.php\');
die();
}
if (array_key_exists(\'movies_view\', $wp->query_vars) && $wp->query_vars[\'movies_view\'] == \'landing\'){
include(TEMPLATEPATH . \'/template-movieslanding.php\');
die();
}
if (array_key_exists(\'movies_view\', $wp->query_vars) && $wp->query_vars[\'movies_view\'] == \'wholesale\'){
include(TEMPLATEPATH . \'/template-movieswholesale.php\');
die();
}
}
}
然后将此var添加到链接中
有关概述,请添加?movies\\u view=登录页添加url概览?movies\\u view=登录url进行批量添加?movies\\u view=批发到url希望这有帮助