On this page
get_comment_type( int|WP_Comment $comment_ID ): string
Retrieves the comment type of the current comment.
Parameters
$comment_IDint|WP_Comment Optional-
WP_Comment or ID of the comment for which to get the type.
Default current comment.
Return
string The comment type.
Source
File: wp-includes/comment-template.php. View all references
function get_comment_type( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
if ( '' === $comment->comment_type ) {
$comment->comment_type = 'comment';
}
/**
* Filters the returned comment type.
*
* @since 1.5.0
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
*
* @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
* @param string $comment_ID The comment ID as a numeric string.
* @param WP_Comment $comment The comment object.
*/
return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
}
Hooks
- apply_filters( 'get_comment_type',
string $comment_type ,string $comment_ID ,WP_Comment $comment ) -
Filters the returned comment type.
Related
Uses
| Uses | Description |
|---|---|
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_comment() wp-includes/comment.php | Retrieves comment data given a comment ID or comment object. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Comments_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Prepares a single comment output for response. |
| WP_REST_Comments_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Updates a comment. |
| get_avatar_data() wp-includes/link-template.php | Retrieves default data about the avatar. |
| comment_type() wp-includes/comment-template.php | Displays the comment type of the current comment. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Added the ability for $comment_ID to also accept a WP_Comment object. |
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_comment_type