WordPress 作者永久链接
我知道如何更改作者永久链接的基数,但是在我的网站上,我不是通过用户名而是通过基于用户 ID 的数字来引用用户,因此 5 号用户写了这篇文章,而不是 JohnDoe123 写了这篇文章。
当我转到用户档案时,问题就出现了,而不是看到类似 example.com/authors/5/ 的内容,而是看到 example.com/authors/johndoe123/ 。
如何更改永久链接以便可以使用以下结构提取作者档案? :
[wordpress_site_url]/authors/[user_ID]/
I know how to change the base of the author permalinks, however on my site, I refer to users not by their username but by a number based on their User ID, so User number 5 wrote this post, rather than JohnDoe123 wrote this post.
The problem comes when I go to that users archives and instead of seeing something like example.com/authors/5/ I see example.com/authors/johndoe123/ .
How do I change permalinks so that I can pull up author archives using the following structure? :
[wordpress_site_url]/authors/[user_ID]/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以通过为每个用户添加新的重写规则来完成,其方式与更改或删除作者库时完全相同。因此,根据之前的答案改编代码,您可以添加重写规则如下:
然后过滤作者链接:
实际上,我认为在这种情况下您不需要为每个用户创建规则,以下两个规则应该足够了:
This can be done by adding new rewrite rules for each user in exactly the same way you would when changing or removing the author base. So, adapting code from a previous answer, you would add your rewrite rules something like this:
And then filter the author link:
Actually I don't think you need to create rules for each user in this case, the following two rules should suffice: