Title: _get_comment_reply_id
Published: March 29, 2023
Last modified: February 24, 2026

---

# _get_comment_reply_id( int|WP_Post $post = null ): int

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/_get_comment_reply_id/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_get_comment_reply_id/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_get_comment_reply_id/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_get_comment_reply_id/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_get_comment_reply_id/?output_format=md#changelog)

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Gets the comment’s reply to ID from the $_GET[‘replytocom’].

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

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
optional

The post the comment is being displayed for.
 Defaults to the current global post.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_get_comment_reply_id/?output_format=md#return)󠁿

 int Comment’s reply to ID.

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

    ```php
    function _get_comment_reply_id( $post = null ) {
    	$post = get_post( $post );

    	if ( ! $post || ! isset( $_GET['replytocom'] ) || ! is_numeric( $_GET['replytocom'] ) ) {
    		return 0;
    	}

    	$reply_to_id = (int) $_GET['replytocom'];

    	/*
    	 * Validate the comment.
    	 * Bail out if it does not exist, is not approved, or its
    	 * `comment_post_ID` does not match the given post ID.
    	 */
    	$comment = get_comment( $reply_to_id );

    	if (
    		! $comment instanceof WP_Comment ||
    		0 === (int) $comment->comment_approved ||
    		$post->ID !== (int) $comment->comment_post_ID
    	) {
    		return 0;
    	}

    	return $reply_to_id;
    }
    ```

[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#L2164)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment-template.php#L2164-L2189)

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

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

Retrieves post data given a post ID or post object.

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

Retrieves comment data given a comment ID or comment object.

  |

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

Retrieves HTML content for cancel comment reply link.

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

Retrieves hidden input HTML for replying to comments.

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

Displays text based on comment reply status.

  |

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

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

## User Contributed Notes

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