Used By
Used By | Description |
---|---|
wp-includes/comment-template.php: wp_list_comments() | Displays a list of comments. |
wp-includes/comment-template.php: comments_template() | Loads the comment template specified in $file. |
Separates an array of comments into an array keyed by comment_type.
(WP_Comment[]) (Required) Array of comments
(WP_Comment[]) Array of comments keyed by comment_type.
File: wp-includes/comment.php
function separate_comments( &$comments ) { $comments_by_type = array( 'comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array(), ); $count = count( $comments ); for ( $i = 0; $i < $count; $i++ ) { $type = $comments[ $i ]->comment_type; if ( empty( $type ) ) { $type = 'comment'; } $comments_by_type[ $type ][] = &$comments[ $i ]; if ( 'trackback' === $type || 'pingback' === $type ) { $comments_by_type['pings'][] = &$comments[ $i ]; } } return $comments_by_type; }
Version | Description |
---|---|
2.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/separate_comments