How to add an inline word after post author commenter name?

I want to add an inline word(s) after comments of post author’s name. Suppose, my name is Tiger and i am the post author, so Post author will be printed after my name every time when i add a comment on the post.

Like this picture

I don’t want to edit comment.php file. I want custom functions for functions.php

Solutions Collecting From Web of "How to add an inline word after post author commenter name?"

Just wanted to mention some alternatives:

Alternative #1

You say you don’t want to edit the comments.php file in the current theme directory. If we need to change how the wp_list_comments() works, we can always modify it through the wp_list_comments_args filter. For example to add our own callback:

add_filter( 'wp_list_comments_args', function( $r )
    if( function_exists( 'wpse_comment_callback' ) )
        $r['callback'] = 'wpse_comment_callback';
    return $r;
} );

where the wpse_comment_callback() callback contains the customization of your comment’s layout.

Alternative #2

If we take a look at e.g. the Twenty Sixteen theme, we will see how the .bypostauthor class is used to mark the post comment author from the stylesheet:

.bypostauthor > article .fn:after {
        content: "\f304";
        left: 3px;
        position: relative;
        top: 5px;

where you could adjust the content attribute to your needs. This might not be the workaround for you, if you need to style it or use words with translations.

You can make use of the get_comment_author filter to adjust the text displayed as comment author name according to your needs. All you need to do is to check who the post author is and then check that against the comment author.

The complete comment object is passed by reference as third parameter to the filter, we can access that object to get the comment author which we can compare to the post_author of the post object

add_filter( 'get_comment_author', function (  $author, $comment_ID, $comment )
    // Get the current post object
    $post = get_post();

    // Check if the comment author is the post author, if not, bail
    if ( $post->post_author !== $comment->user_id )
        return $author;

    // The user ids are the same, lets append our extra text
    $author = $author . ' Post author';

    return $author;
}, 10, 3 );

You can adjust and add styling as needed

EDIT – from comments

As pointed out by @birgire, the get_comment_class() sets the .bypostauthor class for the post author comments.

// For comment authors who are the author of the post
if ( $post = get_post($post_id) ) {
    if ( $comment->user_id === $post->post_author ) {
        $classes[] = 'bypostauthor';

We can also use this to check for comments by the post author. Just a not, it may not be very reliable as it can be overriden by themes or plugins

add_filter( 'get_comment_author', function (  $author )
    if( !in_array( 'bypostauthor', get_comment_class() ) )
        return $author;

    // The user ids are the same, lets append our extra text
    $author = $author . ' Post author';

    return $author;

If I’m not getting it wrong, you are going to add some text to commenter’s name if he is the post author, right?

You need to hook into get_comment_author. Check either the post author is the commenter. If yes, then return your custom text, otherwise return original text.

Use this code-

add_filter( 'get_comment_author', 'add_text_to_comment_author' );
function add_text_to_comment_author( $author ){
    global $post;
    if( get_comment( get_comment_ID() )->user_id == $post->post_author ){
        return "custom text here " . $author;
    return $author;