wp_list_comments()获取所有的评论,可自定义输出样式

目录

描述

Displays all comments for a post or Page based on a variety of parameters including ones set in the administration area.

See also: Migrating Plugins and Themes to 2.7

wp_list_comments() 描述

用法

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

Default Usage

$args

(array) (optional) The options for the function.

Default:

The 'max_depth', 'per_page' and 'reverse_top_level' parameters can be more easily controlled through the Discussion Settings Administration Panel but a theme can override those settings.

$comments

(array) (optional) Array obtained by get_comments query.

Default: The default return of get_comments.

wp_list_comments() 用法

示例

Default Usage

Outputs an ordered list of the comments. Things like threading or paging being enabled or disabled are controlled via the Settings Discussion SubPanel.

Comments Only With A Custom Comment Display

Displays just comments (no pingbacks or trackbacks) while using a custom callback function to control the look of the comment. You may want to add a max_depth=X parameter, if the reply links are not appearing.

You will need to define your custom callback function in your theme's functions.php file. Here is an example:

Note the lack of a trailing </li>. In order to accommodate nested replies, WordPress will add the appropriate closing tag after listing any child elements.

Display Comments for a Specific Page/Post

Outputs an ordered list of comments for a specific page or post. Things like threading or paging being enabled or disabled are controlled via the Settings Discussion SubPanel.

wp_list_comments() 示例

历史

添加于 版本: 2.7.0

wp_list_comments() 历史

源文件

wp_list_comments() 函数的代码位于 wp-includes/comment-template.php.

wp_list_comments() 源文件

相关