首页    >    中文手册    >   模板标签-comments_popup_link()

模板标签-comments_popup_link()

说明

在使用comments_popup_script的情况下,该标签显示评论弹出式窗口的链接,若未使用comments_popup_script,该标签显示评论的常规链接。该标签必须用在WordPress主循环(loop)或评论循环中。若 is_single()is_page()函数值为true,该标签将无法作用(即使在主循环内)。

用法

<?php comments_popup_link
('zero','one','more','CSSclass','none');
?>

示例

与评论总数相应的文本信息

根据评论总数显示相应文本信息:评论总数为0——目前尚无评论;评论总数为1——有1条评论;评论总数超过1 ——"% comments so far"(目前为止有%条评论,用评论总数代替其中的“%”);禁用评论时—— "Comments are off for this post"(评论被关闭)。此外,'comments-link'是链接的一个自定义CSS类。

<p><?php comments_popup_link('No comments yet', '1 comment so far',
'% comments so far (is that a lot?)', 'comments-link', 'Comments are
off for this post'); ?></p>

评论被关闭时,隐藏评论链接

如果在管理界面禁用了评论功能,那么可以隐藏包含comments_popup_link的段落元素<p></p>。这种方法适用于那些希望在某些文章中激活评论、在另一些文章中禁用评论的用户。不过这种方法必须用在循环中。

<?php if ( comments_open() ) : ?>
<p>
<?php comments_popup_link( 'No comments yet', '1 comment', '% comments so far', 'comments-link', 'Comments are off for this post'); ?>
</p>
<?php endif; ?>

参数

zero

(字符串)无评论时所显示的文本信息。默认为'No Comments'(无评论)。

one

(字符串)只有一条评论时所显示的文本信息。默认为'1 Comment'(1条评论)。

more

(字符串)评论总数超过1时所显示的文本信息。% 会被评论总数取代,因此'% so far' 在页面上显示为 "5 so far"(目前为止,该文章有5条评论)。默认为 '% Comments'。

CSSclass

(字符串)链接的CSS(样式表)类。无默认值。

none

(字符串)禁止评论时显示的文本信息。默认为 'Comments Off'(评论被关闭)。

分类:中文手册

* 版权声明:作者WordPress啦! 转载请注明出处。