【发布时间】:2021-10-13 01:23:58
【问题描述】:
我的帖子的 URL 如下:
http://example.com/news/postname
wp-admin 中的“自定义结构”设置如下:
http://example.com[/news/%postname%]
我想以我的帖子开头的帖子名称的 URL(例如 mypost-postname)更改为
http://example.com/my-news/postname
我尝试像这样使用 add_rewrite_rule:
add_action( 'init', 'new_posts_with_new_url' );
function new_posts_with_new_url()
{
add_rewrite_rule('my-news/([^/]*)/?','index.php?pagename=news/mypost-$matches[1]','top');
}
但它似乎不起作用。
我做错了哪一步?非常感谢。
【问题讨论】:
标签: wordpress url-rewriting add rules