我有一个类在循环中生成自定义重写 .
比如下面的例子
foreach($pages as $page)
{
$cityRewrite = sprintf('^(%s)/(%s)?$', substr($permalink['permalink'],1), $page->post_name);
$cityRewriteLocation = sprintf('index.php?page_id=%s&city=%s', $page->ID, $permalink['city_id']);
add_rewrite_rule($cityRewrite, $cityRewriteLocation,'top');
}
这很好用,并产生了不止一些重写 .
wp-cli rewrite list
采用以下格式:
^(the-city)/(checkout)?$ | index.php?page_id=[integer-here]&city=[uuid-here]
...
今天有些东西破了,突然所有页面都返回404.几小时后我发现这是由插件Yoast SEO引起的,它似乎消除了我的自定义类创建的所有重写 .
所以我的问题是 .
-
我是否通过在wordpress 'init' 动作上运行这个自定义重写循环来做错事?
-
使用Yoast SEO时,你应该以不同的方式处理自定义重写吗?
-
这可能只是Yoast SEO中的一个错误吗?