Mik*_*ike 1 wordpress permalinks
我们公司的博客有 3 位作者,每个作者在个人资料设置中都有自己的网站网址:
Mike - http://mike.com
Gelens - http://gelens.com
Admin - http://site.com/company/
Run Code Online (Sandbox Code Playgroud)
个人资料的链接是:
http://site.com/author/Mike/
http://site.com/author/Gelens/
http://site.com/author/Admin/
Run Code Online (Sandbox Code Playgroud)
我需要替换一个到管理员页面的链接,所以,如果<?php the_author_posts_link(); ?>某个页面上有标签,并且作者是管理员,那么链接必须是http://site.com/company/而不是http://site.com/author/Admin/.
我怎样才能做到这一点?
看起来该the_author_posts_link函数只是调用get_author_posts_url获取链接,该链接author_link在返回之前通过过滤器传递链接。在您的主题中functions.php,您可以添加如下内容(未经测试):
add_filter( 'author_link', 'admin_author_link', 10, 3);
功能 admin_author_link($link, $author_id, $author_nicename) {
如果($author_id==1){
$link = 'http://site.com/company/';
}
返回 $link;
}
| 归档时间: |
|
| 查看次数: |
5303 次 |
| 最近记录: |