Wordpress评论模板函数集-Comment Template Tags

网站的内容大多都对读者开放评论,读者与作者的沟通和交流更直接更快捷,提高了用户的体验,现整理评论模板相关函数如下。

<?php comments_number(‘zero’, ‘one’, ‘more’, ‘number’); ?> ,评论数量(Comment Count)

显示文章回复, Trackbacks, Pingbacks 总数。

参数说明:

  • zero::string类型参数,无评论时显示的文本。
    <?php comments_number(‘No Comments’, ’one’, ’more’, ’number’); ?>
  • one:string类型参数,1条评论时显示的文本。
    <?php comments_number(‘zero’, ’1 Comment’, ’more’, ’number’); ?>
  • more:string类型参数,多条评论时显示的文本样式。% 代表评论数量。 
    <?php comments_number(‘zero’, ’one’, ’% Comments’, ’number’); ?>
  • number:Interger类型参数,指定显示具体个数的评论。
    <?php comments_number(‘zero’, ’one’, ’more’, ’5′); ?>

<?php comments_link(); ?> ,指向文章评论页面的链接(Link to post comments),无参数。

<?php comments_rss_link(‘text’, ‘file’); ?> ,文章评论RSS FEED 链接。

参数说明:

  • text:评论 RSS链接文本,默认值为Comment RSS。
    <?php comments_rss_link(‘RSS’, ’file’); ?>
  • file:链接到具体文件,默认值为 wp-commentsrss2.php 。
    <?php comments_rss_link(‘text’, ’wp-commentsrss2.php’); ?>

<?php comments_popup_script(width, height); ?> ,在评论弹出窗口中输出Javascript代码,此代码通常放置在<head>部分。

参数说明:

  • width:弹出窗口的宽度,默认值为400px。
    <?php comments_popup_script(300, height); ?>
  • height:弹出窗口高度,默认值为300px。
    <?php comments_popup_script(width, 300); ?>

<?php comments_popup_link (‘zero’,'one’,'more’,'CSSclass’,'none’); ?>,弹出窗口链接(Link  to Pop-Up Window)。在comments_popup_script()开启的情况下,会显示一个指向文章评论弹出窗口的链接,否则显示一个指向评论页面的链接,此代码只能在循环(loop)中使用,而且不能用在is_single() 或者is_page() 为 true情况下。

参数说明:

  • zero:string类型参数,无评论时显示的文本样式。
    <?php comments_popup_link (‘No Comments’,'one’,'more’,'CSSclass’); ?>
  • one:string类型参数,只有一条评论时显示的文本样式。
    <?php comments_popup_link (‘zero’,'1 Comment’,'more’,'CSSclass’); ?>
  • more:string类型参数,多条平时时显示的文本样式。
    <?php comments_popup_link (‘zero’,'one’,'% Comments’,'CSSclass’); ?>
  • CSSclass:链接样式。
    <?php comments_popup_link (‘zero’,'one’,'more’,'popup-link’); ?>
  • none:评论关闭。
    <?php comments_popup_link (‘none’); ?>

<?php comment_ID(); ?> ,评论ID(Comment ID),无参数,只能用在Loop循环或Comment Loop循环中。

<?php comment_author(); ?>,评论作者,无参数,只能用在Loop循环或Comment Loop循环中。

<?php comment_author_IP(); ?> ,评论作者的IP,无参数,只能用在Loop循环或Comment Loop循环中。

<?php comment_author_email(); ?> ,评论作者的Email,无参数,只能用在Loop循环或Comment Loop循环中。

<?php comment_author_url(); ?> ,显示评论作者的URL文本(不是链接),无参数,只能用在Loop循环或Comment Loop循环中。

<?php comment_author_email_link(‘linktext’, ‘before’, ‘after’); ?> ,评论作者的Email链接,只能用在Loop循环或Comment Loop循环中。

参数说明:

  • linktext:Email 链接文本,默认为邮箱地址。
    <?php comment_author_email_link(‘Email’, ’before’, ’after’); ?>。
  • before:链接文本前缀。
    <?php comment_author_email_link(‘linktext’, ’&raquo;’, ’after’); ?>。
  • after:链接文本后缀。
    <?php comment_author_email_link(‘linktext’, ’before’, ’&laquo;’); ?>
除非注明,本博客文章均为原创,转载请以链接形式标明本文地址
原创文章如转载,请注明:转载自 任鸟飞网页设计 [ http://www.renniaofei.com/ ]
本文链接地址: http://www.renniaofei.com/code/wordpress-function-comment-template-tags/
引用通告地址 Trackback URL:直接在本文链接地址后添加 trackback/
本文短网址: http://bit.ly/cNrpnv
任鸟飞

任鸟飞网页设计网创办者 主要关注网页设计,网站建设,图形图像设计。 Twitter @renniaofei QQ:29900684

2 条评论

  1. MC 七月 15th, 2010   7:15 下午

    评论循环咋写啊?

  2. mysuperwoofer 七月 19th, 2010   6:20 下午

    如何增加外链,我的外链1400,如何加到5000,大家是手动加的吗,一个站一个站加的吗,太花时间了,自动链接

留下评论

:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!: