的连词add_rewrite_rule()
&;add_rewrite_tag()
有点棘手,也许你可以parse_url
钩住对我有用的东西。下面的代码用于捕获多个参数=用斜杠分隔的值。代码-
add_filter( \'parse_request\', \'wpse128790_parse_request\' );
function wpse128790_parse_request( $wp )
{
$pageslug = \'mypage\';
if( isset($wp->request) && strpos($wp->request, \'/\') )
{
$requests = explode(\'/\', $wp->request);
if( $pageslug == array_shift($requests) )
{
$wp->set_query_var(\'pagename\', $pageslug);
$wp->set_query_var(\'attachment\', false );
$wp->set_query_var(\'error\', false );
$count = count( $requests );
if( $count > 0 )
{
// stop the canonical redirection
remove_action(\'template_redirect\', \'redirect_canonical\');
foreach( $requests as $i => $request )
{
// this should be the key, and next one will be the value
if( $i == 0 || $i % 2 == 0 )
{
if( isset($requests[$i+1]) )
$val = $requests[$i+1];
else
$val = \'\';
$wp->set_query_var( $request, $val );
}
}
}
}
}
}
但您可能会使用in\\u array或其他方法过滤参数,以确保包含在中是安全的
wp query var