在wordpress表单上,当您以访客身份发表评论时,会有一个网站字段填写您的网址.如果填写该框,则可以通过调用此函数来获取链接
<?php echo get_comment_author_link(); ?>
但是,如果您已登录并且没有在评论中添加网站,则不会在个人资料中添加该网站.您的用户名上没有链接.
我想要的是,如果登录的用户没有该网站,则将有一个链接将其带到其个人资料页面,类似于http://www.example.com?author=21
我在那里可以使用任何功能吗?请帮帮我.谢谢.
解决方法:
将其放在主题的functions.php中;
function force_comment_author_url($comment)
{
// does the comment have a valid author URL?
$no_url = !$comment->comment_author_url || $comment->comment_author_url == 'http://';
if ($comment->user_id && $no_url) {
// comment was written by a registered user but with no author URL
$comment->comment_author_url = 'http://www.example.com/?author=' . $comment->user_id;
}
return $comment;
}
add_filter('get_comment', 'force_comment_author_url');
原文地址:https://codeday.me/bug/20191009/1878245.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。