0
稱之爲強迫症或迫切需要將邏輯與表示分開,但我討厭關於wp_list_comments()的所有內容 - 以及在某種程度上,comment_form() - 我想知道是否任何人都有一個很好的例子來循環評論它以前的做法。WordPress的評論和開水wp_list_comments()
我知道那裏的回調和我的選擇,但我不喜歡那個選項。
任何幫助或正確的方向點讚賞。
乾杯。
稱之爲強迫症或迫切需要將邏輯與表示分開,但我討厭關於wp_list_comments()的所有內容 - 以及在某種程度上,comment_form() - 我想知道是否任何人都有一個很好的例子來循環評論它以前的做法。WordPress的評論和開水wp_list_comments()
我知道那裏的回調和我的選擇,但我不喜歡那個選項。
任何幫助或正確的方向點讚賞。
乾杯。
我寫了一篇關於此的小文章。 here
Theres有幾種方式來拉動信息,但我喜歡這樣做...... 使用get_comments()函數,你可以建立大多數你需要的東西。
<?php
$recent_comments = get_comments(array(
'number' => 5,
'status' => 'approve',
'type' => 'comment'
));
?>
上$做一個print_r的recent_comments
<?php
echo "<pre>";
print_r($recent_comments);
echo "</pre>";
?>
[0] => stdClass Object
(
[comment_ID] => 23387
[comment_post_ID] => 32
[comment_author] => Marty
[comment_author_email] => [email protected]
[comment_author_url] => http://www.website.com
[comment_author_IP] => 11.111.11.111
[comment_date] => 2010-09-22 08:09:24
[comment_date_gmt] => 2010-09-22 07:09:24
[comment_content] => the content of the comment
[comment_karma] => 0
[comment_approved] => 1
[comment_agent] => Mozilla
[comment_type] =>
[comment_parent] => 0
[user_id] => 2
[comment_subscribe] => N
)
然後只是做一個for循環的在每個評論和展示工作或隱瞞你想要什麼..
<?php
foreach ($recent_comments as $comment)
{
?>
<li>
<a href="<?php echo get_permalink($comment->comment_post_ID);?>" title="<?php echo $comment->comment_author;?> on <?php echo get_the_title($comment->comment_post_ID); ?>">
<?php echo get_avatar($comment->comment_author_email, '55'); ?>
</a>
<h3>
<a href="<?php echo get_permalink($comment->comment_post_ID);?>#comment-<?php echo $comment->comment_ID;?>" title="<?php echo $comment->comment_author;?> on <?php echo get_the_title($comment->comment_post_ID); ?>">
<?php echo get_the_title($comment->comment_post_ID); ?>
</a>
</h3>
By: <?php echo $comment->comment_author;?>
</li>
<?php
}
?>
鉤住get_avatar()功能,這將讓你從那裏生成一個圖像的電子郵件地址,如果他們有一個...
<?php echo get_avatar($comment->comment_author_email, '55'); ?>