在wordpress表单中,当您将评论留为guest时,会有一个网站字段来填写您的网址。如果我们填写了那个框,我们就可以通过调用这个函数来获得链接
<?php echo get_comment_author_link(); ?>但是如果你已经登录了,并且你没有在你的个人资料中添加网站,当你留下评论的时候。你的用户名上没有链接。
我想要的是,如果登录的用户没有网站,将有一个链接,这将把他们带到他们的个人资料页面,这是类似http://www.example.com?author=21的东西
有没有什么我可以使用的函数?请帮帮我。谢谢。
发布于 2010-05-01 05:13:24
把这个放到你的主题的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');发布于 2010-04-30 22:50:14
好吧,我想一个解决办法是让一个php/mySQL脚本将wordpress数据库中的空数据库字段更新为您想要的值。
https://stackoverflow.com/questions/2742246
复制相似问题