wp_list_comments [ WordPress Function ]
wp_list_comments ( $args = array(), $comments = null )
| Parameters: |
|
| Uses: |
|
| Defined at: |
|
Soorgelijke functies: wp_insert_comment, wp_delete_comment, wp_filter_comment, wp_list_cats, wp_count_comments
List comments
Used in the comments.php template to list comments for a particular post
Source
<?php
function wp_list_comments($args = array(), $comments = null ) {
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
$in_comment_loop = true;
$comment_alt = $comment_thread_alt = 0;
$comment_depth = 1;
$defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
$r = wp_parse_args( $args, $defaults );
// Figure out what comments we'll be looping through ($_comments)
if ( null !== $comments ) {
$comments = (array) $comments;
if ( empty($comments) )
return;
if ( 'all' != $r['type'] ) {
$comments_by_type = &separate_comments($comments);
if ( empty($comments_by_type[$r['type']]) )
return;
$_comments = $comments_by_type[$r['type']];
} else {
$_comments = $comments;
}
} else {
if ( empty($wp_query->comments) )
return;
if ( 'all' != $r['type'] ) {
if ( empty($wp_query->comments_by_type) )
$wp_query->comments_by_type = &separate_comments($wp_query->comments);
if ( empty($wp_query->comments_by_type[$r['type']]) )
return;
$_comments = $wp_query->comments_by_type[$r['type']];
} else {
$_comments = $wp_query->comments;
}
}
if ( '' === $r['per_page'] && get_option('page_comments') )
$r['per_page'] = get_query_var('comments_per_page');
if ( empty($r['per_page']) ) {
$r['per_page'] = 0;
$r['page'] = 0;
}
if ( '' === $r['max_depth'] ) {
if ( get_option('thread_comments') )
$r['max_depth'] = get_option('thread_comments_depth');
else
$r['max_depth'] = -1;
}
if ( '' === $r['page'] ) {
if ( empty($overridden_cpage) ) {
$r['page'] = get_query_var('cpage');
} else {
$threaded = ( -1 != $r['max_depth'] );
$r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
set_query_var( 'cpage', $r['page'] );
}
}
// Validation check
$r['page'] = intval($r['page']);
if ( 0 == $r['page'] && 0 != $r['per_page'] )
$r['page'] = 1;
if ( null === $r['reverse_top_level'] )
$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
extract( $r, EXTR_SKIP );
if ( empty($walker) )
$walker = new Walker_Comment;
$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
$wp_query->max_num_comment_pages = $walker->max_pages;
$in_comment_loop = false;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- wp_list_comments - WordPress Codex
Description. 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 ...
codex.wordpress.org - WordPress › Support » wp_list_comments
I am having a crazy amount of trouble with wp_list_comments(). I am trying to create my own custom function to display comments. Within the_loop I have: ...
wordpress.org - Customising wp_list_comments() — studiograsshopper
Sep 8, 2009 ... wp_list_comments(). I'm not going to repeat all that can be found on the Codex, see wp_list_comments() for details, but essentially the function ...
www.studiograsshopper.ch - How to customize the comments template or wp_list_comments ...
Mar 1, 2010 ... From wordpress 2.7 version we got the functionality of changing or customizing the comments template as per your theme. As we all know in ...
wordpressapi.com
Gebruikersdiscussies [ wordpress.org ]
- buaidh on "Pagination for wp_list_comments"
- buaidh on "Pagination won't appear/work for wp_list_comments query"
- alchymyth on "Customizing children comments in wp_list_comments"
- yans_fied on "Customizing children comments in wp_list_comments"
- alchymyth on "Customizing children comments in wp_list_comments"
- yans_fied on "Customizing children comments in wp_list_comments"
- Jeremy Story on "[Theme: Frisco for BuddyPress] Frisco and Comments"
- bapo_10@hotmail.com on "Problems in converting template to indented comments with wp_list_comments"
- alxvallejo on "Parameters in wp_list_comments"
- Rubyfire on "wp_list_comments"