Title: Walker_Comment::start_el
Published: April 25, 2014
Last modified: April 28, 2025

---

# Walker_Comment::start_el( string $output, WP_Comment $data_object, int $depth, array $args = array(), int $current_object_id )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#changelog)

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

Starts the element output.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/classes/walker_comment/start_el/?output_format=md#see-also)󠁿

 * [Walker::start_el()](https://developer.wordpress.org/reference/classes/Walker/start_el/)
 * [wp_list_comments()](https://developer.wordpress.org/reference/functions/wp_list_comments/)

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

 `$output`stringrequired

Used to append additional content. Passed by reference.

`$data_object`[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
required

Comment data object.

`$depth`intoptional

Depth of the current comment in reference to parents. Default 0.

`$args`arrayoptional

An array of arguments.

Default:`array()`

`$current_object_id`intoptional

ID of the current comment. Default 0.

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

    ```php
    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {
    	// Restores the more descriptive, specific name for use within this method.
    	$comment = $data_object;

    	++$depth;
    	$GLOBALS['comment_depth'] = $depth;
    	$GLOBALS['comment']       = $comment;

    	if ( ! empty( $args['callback'] ) ) {
    		ob_start();
    		call_user_func( $args['callback'], $comment, $args, $depth );
    		$output .= ob_get_clean();
    		return;
    	}

    	if ( 'comment' === $comment->comment_type ) {
    		add_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40, 2 );
    	}

    	if ( ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) && $args['short_ping'] ) {
    		ob_start();
    		$this->ping( $comment, $depth, $args );
    		$output .= ob_get_clean();
    	} elseif ( 'html5' === $args['format'] ) {
    		ob_start();
    		$this->html5_comment( $comment, $depth, $args );
    		$output .= ob_get_clean();
    	} else {
    		ob_start();
    		$this->comment( $comment, $depth, $args );
    		$output .= ob_get_clean();
    	}

    	if ( 'comment' === $comment->comment_type ) {
    		remove_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40 );
    	}
    }
    ```

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

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

| Uses | Description | 
| [Walker_Comment::html5_comment()](https://developer.wordpress.org/reference/classes/walker_comment/html5_comment/)`wp-includes/class-walker-comment.php` |

Outputs a comment in the HTML5 format.

  | 
| [Walker_Comment::comment()](https://developer.wordpress.org/reference/classes/walker_comment/comment/)`wp-includes/class-walker-comment.php` |

Outputs a single comment.

  | 
| [Walker_Comment::ping()](https://developer.wordpress.org/reference/classes/walker_comment/ping/)`wp-includes/class-walker-comment.php` |

Outputs a pingback comment.

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

Adds a callback function to a filter hook.

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

Removes a callback function from a filter hook.

  |

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

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

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Renamed `$comment` to `$data_object` and `$id` to `$current_object_id` to match parent class for PHP 8 named parameter support. | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## User Contributed Notes

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