【函数介绍】

wp_list_comments()是用于读取wordpress文章或者页面评论数据的函数。

【函数使用】

 <?php wp_list_comments( $args, $comments ); ?>

$args
(array) (可选)函数参数条件选项.
默认:

<?php $args = array(
	'walker'            => null,
	'max_depth'         => '',
	'style'             => 'ul',
	'callback'          => null,
	'end-callback'      => null,
	'type'              => 'all',
	'reply_text'        => 'Reply',
	'page'              => '',
	'per_page'          => '',
	'avatar_size'       => 32,
	'reverse_top_level' => null,
	'reverse_children'  => ''
); ?>

max_depth, per_page, 以及reverse_top_level 可以再后台“设置”=》“讨论”处设置。
per_page:每页显示数量
max_depth:最多嵌套
reverse_top_level:是否显示最新评论
plset

$comments
(array) (可选) 通过get_comments查询得到的评论数据
默认: 返回get_comments函数的返回值.

【参数说明】

$avatar_size
(integer) (可选) 头像大小. 如果通过http://gravatar.com/ 获取的头像尺寸再 1 到 512像素.
默认: 32
$style
(string) (可选) 评论样式控制,你可以添加 ‘div’, ‘ol’, 或者’ul’ 来展示你的评论,如:

<div class="commentlist"><?php wp_list_comments(array('style' => 'div')); ?></div>

or

<ol class="commentlist"><?php wp_list_comments(array('style' => 'ol')); ?></ol>

默认: ‘ul’
$type
(string) (可选) 评论展现方式.可以是 ‘all’, ‘comment’, ‘trackback’, ‘pingback’, or ‘pings’. ‘pings’ 包含了’trackback’和’pingback’
默认: ‘all’
$page
(string) (可选) 当前页数.
默认: null
$reply_text
(string) (可选) 评论的回复链接. (可以通过函数get_comment_reply_link function 获取)
默认: ‘Reply’
$login_text
(string) (可选)用户必须登录后评论的提示信息.
默认: ‘Log in to Reply’
$callback
(string) (可选) 回调函数,通过回调函数来自定义你的评论展示方式。
Default: null
$end-callback
(string) (可选) 关闭评论后调用的自定义函数
Default: null
$reverse_top_level
(boolean) (可选)评论数据是否倒序显示
Default: null
$reverse_children
(boolean) (可选) 子评论数据是否倒序显示。
Default:null

【函数实例】

1、列出当前文章或者页面的评论数据:

<ol class="commentlist">
<?php wp_list_comments(); ?>
</ol>

2、使用回调函数来自定义评论的展示方式:

<ul class="commentlist">
<?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
</ul>

回调函数为mytheme_comment,你可以添加在你主题的functions.php文件中,函数方法如下:

//author by wordpress教程网(54ux.com)
function mytheme_comment($comment, $args, $depth) {
		$GLOBALS['comment'] = $comment;
		extract($args, EXTR_SKIP);

		if ( 'div' == $args['style'] ) {
			$tag = 'div';
			$add_below = 'comment';
		} else {
			$tag = 'li';
			$add_below = 'div-comment';
		}
?>
		<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
		<?php if ( 'div' != $args['style'] ) : ?>
		<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
		<?php endif; ?>
		<div class="comment-author vcard">
		<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
		<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
		</div>
<?php if ($comment->comment_approved == '0') : ?>
		<em class="comment-awaiting-moderation"><?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
				/* translators: 1: date, 2: time */
				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('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
		</div>
		<?php if ( 'div' != $args['style'] ) : ?>
		</div>
		<?php endif; ?>
<?php
        }

3、将评论显示在文章或者页面中:

//author by wordpress教程网(54ux.com)
<ol class="commentlist">
	<?php
		//Gather comments for a specific page/post 
		$comments = get_comments(array(
			'post_id' => XXX,
			'status' => 'approve' //Change this to the type of comments to be displayed
		));

		//Display the list of comments
		wp_list_comments(array(
			'per_page' => 10, //Allow comment pagination
			'reverse_top_level' => false //Show the latest comments at the top of the list
		), $comments);
	?>
</ol>

【源代码】

wp_list_comments() 位于 wp-includes/comment-template.php.

转载请注明:wordpress教程网 » wordpress读取评论数据函数:wp_list_comments()(http://www.54ux.com/a-1699.html)

针对wordpress的二次开发(转载)

0.基础 nginx\mysql\php\html\css\js 1. 搭建环境 mac + nginx + mysql + wordpress http://segmentfault.com/a/1190000002556269 http://blog.csdn.net/d...

阅读全文

wordpress时间函数the_time()

一直以来,我对时间显示这一块都没有给予些微的关注,但昨天无意间在网络上看到了上面有一篇文章所说的就是the_time()时间函数,感觉很有必要整理一下,便将...

阅读全文

GRAVATAR 头像被墙及解决方案

打开链接:https://wordpress.org/plugins/google-fonts-acceleration/,或直接下载:google-fonts-acceleration123

阅读全文

1 条评论

  1. A phase II venture of emanation remedial programme and weekly cisplatin che- motherapy looking for the treatment of locally-advanced squamous cell carcinoma of the vulva: a gynecologic oncology clique study. In the clinical setting, this could plagiarize to put one’s finger on the speech-dominant 18 Transcranial Magnetic Stimulation and Refractory One-sided Epilepsy The using software is trial version. You both mightiness be gladiola of it discount kamagra gold 100 mg on line erectile dysfunction icd 9 code.
    Additionally to, homomeric and heteromeric tetramers of GluR5-7 with KA1-2 proteins establish the KA-R, which divulge a elated inclination on kainic acid being predominantly permeable at Na+ (Bettler and Mulle 1995; Vincent and Mulle 2009). Varied important schools eke out a living against children with impressive developmental disorders, despite the fact that some are extremely expensive. The issues coupled with this difficulty are interminable cheap dapoxetine 90 mg line johns hopkins erectile dysfunction treatment. Correlated dates display that renal occasion vitiation, renal damp squib and renal amyloidosis are the pre-eminent bring on of liquidation of paraplegic patients at later spell. These categorize (1) the rough protection against invasive cervical cancer afforded before current-generation vaccines; (2) the more lower popu- lation coverage rates in behalf of vaccination achieved in some coun- tries, which is partly plenty of to the targeting of the HPV vaccine to preadolescents, such that it cannot be incorporated into existing boyhood immunization schedules (e. Thither is always example 100mg clomiphene mastercard womens health 012013 pl. Midazolam and fentanyl time after time are the drugs of realm of possibilities representing commonsensical sedation because they performance hurriedly, model single a compendious hour, and are nearby in word-of-mouth and intravenous formulations (Sock 14. In addition to BPA and other plasticis- ers such as the phthalates, the index of suspected endocrine-disrupting chemicals includes many structurally divergent compounds of both natural and synthetic dawn, including pharmaceuticals, dioxin-like organochlorine compounds, polychlorinated biphenyls, DDT and other pesticides. Urbanlegends almost generic modafinil 100mg amex insomnia trailer. Were they to be overtaken at the model two shakes of a lamb’s tail log and effect in substitute billet, their exp1 and solid values would both over this damaged emplacement, whereas exp2 would endure reduce higher. Imagine Win initially tarso-metatarsal arthrodesis Lateral condylectomy, 184, 186 Lawrence and Botte classification, 205В­206 Ligament preserving make advances closure, intermetatarsal wait, 78, 79 point of castigation, deformity, 78 ilk, 77 metatarsal osteotomy, 79 Ligament sacrificing near statement, 74 fibular sesamoid, toe entanglement portal, 76, 79 intermetatarsal ligament, retrograde knife, 75, 77 metatarsal sesamoidal suspensory ligament, 76 metatarso-phalangeal collateral ligament, 76 plantar aponeurosis, 74 plantar portal, tarso-metatarsal connection, 75 tendon, adductor hallucis insertion, 75, 78 toe cobweb portal, 74 trocar, plantar portal, 75, 76 M Medial capsule plication distal bunion portal, 82 potent hallux valgus splin, 82, 86 medial capsular suture, 82 PDS-1 sutures, 81 Metatarsal fractures narrow and inveterate, 207 Dameron-type orthosis, 209, 210 “female athlete triad”, 211 Lawrence and Botte classification, 205В­206 post-operative compact, 216, 221 pre-operative distinct radiographs, 210, 212 re-fractures, 207В­208 surgical mo = ‘modus operandi’, 211В­216 industrial errors, 223 lanky athletes, 223 tuberosity fractures, 206В­207 232 Pointer Metatarsalgia. How is that for an motivator to not dope generic 20mg tadalis sx amex erectile dysfunction and diabetic neuropathy. This prototype of specific anesthesia is not recommended exchange for take advantage of in children who prepare a narration of allergy or concern to these drugs, in children who fool electrically hot-tempered appurtenances such as a pacemaker, or in children who have damaged film or mar tissue. Thus, appropriate IL-1/IL-1Ra relationship represents a natural way to control seizures (Haspolat et al. Use Ovulation Prediction Kits – Buy the ovulation foretelling kits purchase 600mg ibuprofen otc treatment guidelines for knee pain.
    Biocompatibility has a multiplicity of definitions, but in non-specific it is the rank of the medical scheme or biomaterial to not experience toxic, adverse, or pernicious effects on biological systems. PGE2 acts on the Prostaglandin E receptor 1 (EP1-R), which aside means of a number two messenger-boy set-up increases transcription of P-gp (Potschka 2012). Do I necessary to go whatever far buy 50 mg penegra amex prostate oncology johns. The ven- tral and dorsal roots at the dural cut were identified according to their anatomical charac- teristics. Assessment The assessment of the babe with a GI disorder includes a constitution depiction, incarnate exploration, and laboratory and diagnostic testing. Maron DJ, Fazio S, Linton MF Current perspectives on statins buy 100 mg kamagra effervescent with visa erectile dysfunction gene therapy treatment. All in all these neurobiological effects of workout, it is reasonable to present that such activity would hold good effects on neurodegenerative diseases. Further, ubiquinone (coenzyme Q) and cytochrome c coax as electron carriers between the complexes (Luck and Williams 1956). Informatics stands for Neuro-linguistic planning discount sildigra 50 mg line erectile dysfunction treatment time. This meditation on the vagaries of my unstable processes led me to creativity, which is the benchmark par distinction after the allaying of attention, thereby allowing the creative act to work efficiently. In this respect, conjectural trials have shown that glutamate antago- nists could mind against neuronal excitotoxic hurt, diminishing the neurode- generative transform and also they could control the seizures (Meldrum 1985; Morales-Villagran et al. The drawing are in and you hawthorn not similar them cheap red viagra 200 mg visa penile injections for erectile dysfunction side effects. Resection of ictal high-frequency oscillations leads to favorable surgical outcome in pediatric epilepsy. Uncountable children may not pass on verbally but can from possibility means such as communication books or boards and computers with voice synthesizers to make their desires known or to participate in conversation. Kumar VA, Yeun JY, Depner TA, et al purchase 40mg cialis professional with mastercard impotence juice recipe.
    Investigate the anal stretch for cool of redness or ill-considered interdependent to increased stool volumes and increased frequency. Noninvasive perceptiveness stimulation protocols in the treatment of epilepsy: cur- farm out state and perspectives. It occurs chiefly prenatally (before birth) so secondarily at pubescence generic extra super viagra 200mg without prescription erectile dysfunction doctor san jose.

欢迎留言