0
我创建了一个comments.php风格在我自己的主题评论。 我在'wp_users'表中添加了一个新的'user_avatar'列。所以人们可以将user_avatars添加到他们的个人资料中。WordPress的评论头像
现在来解决问题。
在模板中我有一个查询,.. 我让代码有点简单。所以你有一个基本的想法,发生了什么。
$global $wpdb;
$user = get_comment_author();
$user_avatar = $wpdb->get_var("SELECT user_avatar
FROM wp_users
WHERE display_name LIKE " . $user . " LIMIT 1");
<div class="col-xs-9">
<h1>
<?php echo $user_avatar ?>
<?php echo get_comment_author(); ?>
</h1>
</div>
<div class="col-xs-3">
<h1 class="text-right">
<i class="glyphicon glyphicon-time"></i>
<?php printf(_x('%s', '%s = human-readable time difference', 'yey'), human_time_diff(get_comment_time('U'), current_time('timestamp'))); ?>
<?php _e('ago'); ?>
</h1>
</div>
</div>
<div class="col-xs-12" style="margin:10px;">
<?php comment_text(); ?>
</div>
该查询无法正常工作。我认为这是因为$用户...如果我vardump $ user_avatar我得到NULL,如果我vardump $用户我得到一个字符串与评论的当前名称。
非常感谢..真是糟糕的错误..仍然需要学习很多php:D! – Karuw