• Could you help with this question:

    I want to display the author name of the last comment of the Post too, see below image:

    Use “Mike” posted the newest comment in this Post, I want this user name to be displayed too.

    How can I do it?

    Many thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • $args = array(
    	'status' => 'approve',
    	'number' => '1',
    	'post_id' => $post->ID,
    );
    
    $comments = get_comments($args);
    foreach($comments as $comment) :
    	echo $comment->comment_author . ' posted the newest comment.';
    endforeach;
    Thread Starter wautom

    (@wautom)

    woah so quick solution, thanks very much.

    But where should I put that block of codes?

    Kind regards

    They should be within the loop in your template where you want to display them. If you don’t know how to do that, I guess you will have to find someone who can do that because each theme is coded differently, so no one can really say where to place it unless they have the understanding of how the theme was coded.

    Thread Starter wautom

    (@wautom)

    OK, so I need to dig into the theme, to find the main loop.

    OK I will do that, and let you know when I found the solution.

    My theme is Mesocolumn.

    Many thanks ..

    Thread Starter wautom

    (@wautom)

    OK, I almost did it, please see here:
    link

    It is MesoColumn theme.
    I added your code to post-meta.php, then it works.

    It is not yet perfect, but I am now already quite happy about this, a billions thanks for your help.

    Kind regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to add last comment author name’ is closed to new replies.