Title: comment_type
Published: April 25, 2014
Last modified: February 24, 2026

---

# comment_type( string|false $comment_text = false, string|false $trackback_text = false, string|false $pingback_text = false )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#wp--skip-link--target)

Displays the comment type of the current comment.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#parameters)󠁿

 `$comment_text`string|falseoptional

String to display for comment type.

Default:`false`

`$trackback_text`string|falseoptional

String to display for trackback type.

Default:`false`

`$pingback_text`string|falseoptional

String to display for pingback type.

Default:`false`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#source)󠁿

    ```php
    function comment_type( $comment_text = false, $trackback_text = false, $pingback_text = false ) {
    	if ( false === $comment_text ) {
    		$comment_text = _x( 'Comment', 'noun' );
    	}
    	if ( false === $trackback_text ) {
    		$trackback_text = __( 'Trackback' );
    	}
    	if ( false === $pingback_text ) {
    		$pingback_text = __( 'Pingback' );
    	}
    	$type = get_comment_type();
    	switch ( $type ) {
    		case 'trackback':
    			echo $trackback_text;
    			break;
    		case 'pingback':
    			echo $pingback_text;
    			break;
    		default:
    			echo $comment_text;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment-template.php#L1187)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment-template.php#L1187-L1208)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#related)󠁿

| Uses | Description | 
| [get_comment_type()](https://developer.wordpress.org/reference/functions/get_comment_type/)`wp-includes/comment-template.php` |

Retrieves the comment type of the current comment.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/comment_type/?output_format=md#comment-content-1407)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/comment_type/#comment-1407)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_type%2F%23comment-1407)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_type%2F%23comment-1407)
 4. **Basic Example**
 5.     ```php
        <p><?php comment_type(); ?> to <?php the_title(); ?>: </p>
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_type%2F%3Freplytocom%3D1407%23feedback-editor-1407)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_type%2F)
before being able to contribute a note or feedback.