• Hi,

    I want to display the link to the parent comment in the header of comments made in reply to another when comment threading is enabled.

    WordPress 3.0+ supports this according to the documentation about comments which says:

    Change to comments UI to show when a comment is replying to another, and link to the parent comment

    What does that mean exactly? And how can I do that?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The doc is referring to the comment UI in the dashboard.

    Try the following:

    if ( $comment->comment_parent ) {
    	$parent = get_comment( $comment->comment_parent );
    	$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
    	printf( 'In reply to <a href="%1$s">%2$s</a>.', $parent_link, $parent->comment_author );
    }

    Ref: /wp-admin/includes/template.php Ln:2065

    Thread Starter jhayrocas

    (@jhayrocas)

    Thanks Joseph,

    The code you gave didn’t work, but tweaked it a little and here’s the one that got working on my blog:

    global $comment;
        if ($comment->comment_parent) {
            $parent_comment = get_comment($comment->comment_parent);
            echo 'in reply to <a>comment_ID, array('get_page_of_comment' => true)))).'">'.$parent_comment->comment_author.'</a>';
        }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display link to parent comment in threaded comments’ is closed to new replies.