wordpress模板标签/wp list comments
-描述:
显示文章或页面的评论。
-使用:
‘max_depth’ => ,
’style’ => ‘ul’,
‘callback’ => null,
‘end-callback’ => null,
‘type’ => ‘all’,
‘page’ => ,
‘per_page’ => ,
‘avatar_size’ => 32,
‘reverse_top_level’ => null,
‘reverse_children’ => ); ?>
cc
(整数)显示的头像像素大小,默认为32,http://gravatar.com/ 支持从1到512。
(字符串)可以为‘div’、‘ol’或‘ul’,各自代表容器,有序列表或无序列表。默认为ul。若有包含标签时必须明确写出:
<ol class=”commentlist”><?php wp_list_comments(array(’style’ => ‘ol’)); ?></ol>
(字符串)要显示评论的类型,可以是’all’, ‘comment’, ‘trackback’, ‘pingback’, 或 ‘pings’。 ‘pings’ 既包括 ‘trackback’ 也包括 ‘pingback’ 。默认都显示(即all)。
(字符串)每个评论中作为回复链接的文本(它不是wp_list_comments的参数,但可以通过函数get_comment_reply_link实现)。默认为’reply‘。
(字符串)如果使用者必须注册并登陆才能评论的文本(它不是wp_list_comments的参数,但可以通过函数get_comment_reply_link实现)。默认为’Log in to Reply‘。
(字符串)用于显示每条评论的自定义函数的名字(不推荐使用)。
-例子:
1.默认使用
</ol>
2.用自定义callback函数控制评论外观,只显示评论(非pingbacks或trackbacks)。若回复链接不出现时,可以加一个max_depth=x参数。
</ul>
需要在functions.php中自定义callback函数,如下例:
<li <?php comment_class(); ?> id=”li-comment-<?php comment_ID() ?>”>
<div id=”comment-<?php comment_ID(); ?>”>
<div class=”comment-author vcard”>
<?php echo get_avatar($comment,$size=’48′,$default=’<path_to_url>’ ); ?>
<?php printf(__(‘<cite class=”fn”>%s</cite> <span class=”says”
>says:</span>’), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == ‘0′) : ?>
<em><?php _e(‘Your comment is awaiting moderation.’) ?></em>
<br />
<?php endif; ?>
<div class=”comment-meta commentmetadata”><a href=”
<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>”>
<?php printf(__(‘%1$s at %2$s’), get_comment_date(), get_comment_time()) ?></a>
<?php edit_comment_link(__(‘(Edit)’),’ ‘,”) ?></div>
<?php comment_text() ?>
<div class=”reply”>
<?php comment_reply_link(array_merge( $args, array(‘depth’ => $depth, ‘max_depth’ =>
$args['max_depth']))) ?>
</div>
</div>
<?php
}
注意:上面代码缺了</li>,当它运行时wordpress会自动加上。
这里有英文原版文档。
右上方更多相关内容/站内搜索-关键词请用空格隔开
I have already seen it somethere…
Maybe, I just translate it form wordpress.org ^-^