Title: WP_Query::the_comment
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_Query::the_comment()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_query/the_comment/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_query/the_comment/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_query/the_comment/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_query/the_comment/?output_format=md#changelog)

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

Sets up the current comment.

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

    ```php
    public function the_comment() {
    	global $comment;

    	$comment = $this->next_comment();

    	if ( 0 === $this->current_comment ) {
    		/**
    		 * Fires once the comment loop is started.
    		 *
    		 * @since 2.2.0
    		 */
    		do_action( 'comment_loop_start' );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-query.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-query.php#L3910)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-query.php#L3910-L3923)

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

 [do_action( ‘comment_loop_start’ )](https://developer.wordpress.org/reference/hooks/comment_loop_start/)

Fires once the comment loop is started.

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

| Uses | Description | 
| [WP_Query::next_comment()](https://developer.wordpress.org/reference/classes/wp_query/next_comment/)`wp-includes/class-wp-query.php` |

Iterates current comment index and returns [WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/) object.

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

Calls the callback functions that have been added to an action hook.

  |

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

Iterate comment index in the comment loop.

  |

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

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

## User Contributed Notes

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