我有一个名为location
我想为每个术语添加“新闻”和“市场”等部分,所以我的url看起来像/location/montreal/news/
在我尝试添加分页之前,它工作得非常好。这是我的代码:
add_action( \'init\', \'region_rewrite\' );
function region_rewrite()
{
global $wp;
$wp->add_query_var( \'section\' );
add_rewrite_rule(
\'^location/([^/]*)/([^/]*)/page/([0-9]+)/?\',
\'index.php?location=$matches[1]§ion=$matches[2]&paged=$matches[3]\',
\'top\'
);
add_rewrite_rule(
\'^location/([^/]*)/([^/]*)/?\',
\'index.php?location=$matches[1]§ion=$matches[2]\',
\'top\'
);
}
我正在使用Rewrite analyser plugin 而且,query\\u vars location、section和paged似乎分配了正确的值。然而,我在尝试访问页面url时遇到404错误,如/location/montreal/news/page/2
. 我还注意到page
变量具有值/2
. 这就是我找不到404的原因吗?任何帮助都将不胜感激!