如何更改 WordPress 作者存档页面的 URL?

发布于 2024-08-27 11:26:36 字数 232 浏览 2 评论 0原文

我想使用 www.example.com/artist/xyz,而不是 www.example.com/author/xyz。

我希望这就像将author.php复制到我的主题目录中的artist.php一样简单,但没有那么幸运。 WordPress 在哪里对作者存档页面进行特殊处理?

.htaccess 重写是另一种选择,但我无法让任何东西与现有的 WordPress 重写规则一起工作。

谢谢,

Instead of www.example.com/author/xyz, I want to use www.example.com/artist/xyz.

I was hoping it was as easy as copying author.php to artist.php in my theme directory, but no such luck. Where does wordpress handle the special processing for the author archive pages?

.htaccess rewriting is another option, but I wasn't able to get anything to work with the existing wordpress rewrite rules.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奶气 2024-09-03 11:26:36

将此代码放入主题的functions.php中:

add_filter(
    'init',
    create_function(
        '$a',
        'global $wp_rewrite;
        $wp_rewrite->author_base = "artist";
        $wp_rewrite->flush_rules();'
    )
);

Place this code in the functions.php of your theme:

add_filter(
    'init',
    create_function(
        '$a',
        'global $wp_rewrite;
        $wp_rewrite->author_base = "artist";
        $wp_rewrite->flush_rules();'
    )
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文