Title: get_comment_to_edit
Published: April 25, 2014
Last modified: February 24, 2026

---

# get_comment_to_edit( int $id ): 󠀁[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)󠁿|false

## In this article

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

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

Returns a [WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
object based on comment ID.

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

 `$id`intrequired

ID of comment to retrieve.

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

 [WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)|false
Comment if found. False on failure.

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

    ```php
    function get_comment_to_edit( $id ) {
    	$comment = get_comment( $id );
    	if ( ! $comment ) {
    		return false;
    	}

    	$comment->comment_ID      = (int) $comment->comment_ID;
    	$comment->comment_post_ID = (int) $comment->comment_post_ID;

    	$comment->comment_content = format_to_edit( $comment->comment_content );
    	/**
    	 * Filters the comment content before editing.
    	 *
    	 * @since 2.0.0
    	 *
    	 * @param string $comment_content Comment content.
    	 */
    	$comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content );

    	$comment->comment_author       = format_to_edit( $comment->comment_author );
    	$comment->comment_author_email = format_to_edit( $comment->comment_author_email );
    	$comment->comment_author_url   = format_to_edit( $comment->comment_author_url );
    	$comment->comment_author_url   = esc_url( $comment->comment_author_url );

    	return $comment;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/comment.php#L110)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/comment.php#L110-L135)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_comment_to_edit/?output_format=md#hooks)󠁿

 [apply_filters( ‘comment_edit_pre’, string $comment_content )](https://developer.wordpress.org/reference/hooks/comment_edit_pre/)

Filters the comment content before editing.

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

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

Acts on text which is about to be edited.

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

Checks and cleans a URL.

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

Calls the callback functions that have been added to a filter hook.

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

Retrieves comment data given a comment ID or comment object.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/get_comment_to_edit/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_comment_to_edit/?output_format=md#)

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

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

## User Contributed Notes

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