I'm working on a comments section for my template. And I need to do something like this:

-This was my original comment
And this is my reply to the original comment.

So I wanna cite the original comment inside the comment that was a reply to the original comment. I var_dumped through everything that get_the_comment(); returns and failed to find any reference to the initial comment whatsoever.

Can you please assist me with that? Cheers!

2 Answers 2


The comment/reply ID is a value actually sent by the form. You are able to retrieve it via $_GET:

// Default is "no reply" eq. 0
$id = 0;
// Handle replies
if ( isset( $_GET['replytocom'] ) )
    $id = filter_var(
        # or:
            'options' => array(
                'min_range' => 1,
            # @link http://www.php.net/manual/en/filter.filters.flags.php
            # 'flags'   => '',
    if ( FALSE === $id )

    $id = absint( $_GET['replytocom'] )

Then you have access to the reply-$id.

  • Hi thanks for the reply! You mean I should put it in the reply comment's <textarea> the original comment? Is this your solution?
    – LoomyBear
    May 26, 2014 at 12:45
  • @LoomyBear I don't know how you exactly set up your comments and the comment reply task. The answer just shows from where you can retrieve the ID.
    – kaiser
    May 26, 2014 at 12:47
  • sorry my bad! I've just carefully searched through the comments DB fields once again and found comment_parent field, which contains the reply ID. Thanks for the input though!
    – LoomyBear
    May 26, 2014 at 12:58
  • @LoomyBear Then please add this as separate answer. You might also want to edit your question and show a bit more of your setup. Thanks.
    – kaiser
    May 26, 2014 at 12:59

Ok my bad!

I've looked through what get_comments(); returns and I found comment_parent field which contains the ID of the initial comment. So in order to add cite of the comment you wanna reply to you need to do the following:

    $pid = get_the_id();            
    $comments = get_comments('post_id='.$pid);

    foreach ( $comments as $comment ) {         
        $cpid = $comment->comment_parent; // Getting the ID of the parent comment
        $comment_parent = get_comment( $cpid );

        // Do comment rendering here

Sorry for bothering everyone. I hope this would help somebody in the future. Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.