向WordPress添加了自定义重写规则,它根本不起作用


added custom rewrite rule to wordpress and it does not work at all

function rewrite_support() {
    $wp_rewrite->flush_rules();
    add_rewrite_rule('^support/category/([^/]+)/?$','support-category/?category=$matches[1]','top');
}
add_action( 'init', 'rewrite_support');

这不起作用有什么原因吗?我已将此代码包含在我的函数.php文件中。

/

支持类别/?类别=类别名称

应重定向至:

/支持/类别

/类别名称

这似乎不起作用:

也许:

add_rewrite_rule('^support-category/([^/]+)/?$','index.php?pagename=support/category&category_name=$matches[1]','top');

add_rewrite_rule('^support/category/([^/]+)/?$','index.php?pagename=support-category&category_name=$matches[1]','top');