Example 1 — Default label
Print the type label.
<p><?php comment_type(); ?> on <?php the_title(); ?></p> How It Works
- The current comment is a normal comment.
comment_type()prints the word Comment.the_title()prints the post title.

In WordPress, comment_type() prints the type of the current comment. The default texts are Comment, Trackback, and Pingback.
A normal comment is written by a visitor. A pingback or a trackback is a notice from another site that linked to your post.
Call it with no text for the defaults, or pass your own text for each type.
comment_type();
comment_type( 'Comment', 'Trackback', 'Pingback' ); | Call | What it does |
|---|---|
comment_type() | Prints the default label for the current comment. |
comment_type( 'Reply', 'Link notice', 'Link notice' ) | Prints your own labels. |
get_comment_type() | Returns comment, pingback, or trackback. |
Any type other than trackback or pingback prints the comment text.
comment_type( string|false $comment_text = false, string|false $trackback_text = false, string|false $pingback_text = false ): void | Parameter | Description |
|---|---|
$comment_text | Optional. Text for a normal comment. Default Comment. |
$trackback_text | Optional. Text for a trackback. Default Trackback. |
$pingback_text | Optional. Text for a pingback. Default Pingback. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The function prints the label. |
Three short theme examples. Each one has a sample output.
Print the type label.
<p><?php comment_type(); ?> on <?php the_title(); ?></p> comment_type() prints the word Comment.the_title() prints the post title.Use your own words for each type.
<span class="type"><?php comment_type( 'Reply', 'Link notice', 'Link notice' ); ?></span> Use get_comment_type() to treat pingbacks in another way.
<?php if ( 'pingback' === get_comment_type() ) : ?>
<p class="ping">Another site linked to this post.</p>
<?php endif; ?> get_comment_type() returns a lowercase type.Print the URL of the comments section of the current post.
12 people found this page helpful