如果查看函数,您将看到有一个错误:
function detail_rewrite_rule( $rules ) {
$newrules = array();
$newrules[\'(.+?)/([^/]+)(/[0-9]+)?/detail/?$\'] = \'index.php?category_name=$matches[1]&name=$matches[2]&page=$matches[3]&detail=1\';
return $newrules + $rules;
}
add_filter( \'rewrite_rules_array\',\'detail_rewrite_rules\' );
回调不同:
detail_rewrite_rule
,
detail_rewrite_rules
.
在add\\u过滤器中,必须为函数提供相同的名称。否则,这将不会被WordPress钩住。因此,您可以通过以下方式进行修复:
add_filter( \'rewrite_rules_array\',\'detail_rewrite_rule\' );//without the s