Walker::start_el() WordPress Method

The Walker::start_el() method is used to start the process of walking through a tree of objects. It is called once for each object in the tree. The method takes two parameters: the Walker object and the object currently being processed.

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

Starts the element output.


Description

The $args parameter holds additional values that may be used with the child class methods. Also includes the element output.


Top ↑

Parameters

$output

(string)(Required)Used to append additional content (passed by reference).

$data_object

(object)(Required)The data object.

$depth

(int)(Required)Depth of the item.

$args

(array)(Optional)An array of additional arguments.

Default value: array()

$current_object_id

(int)(Optional) ID of the current item. Default 0.


Top ↑

More Information

This method is abstract and should be explicitly defined in the child class, as needed. Also note that $output is passed by reference, so any changes made to the variable within the following methods are automatically handled (no return, echo, or print needed).

“Start Element”. Generally, this method is used to add the opening HTML tag for a single tree item (such as <li>, <span>, or <a>) to $output.


Top ↑

Source

File: wp-includes/class-wp-walker.php

	public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Renamed $object (a PHP reserved keyword) to $data_object for PHP 8 named parameter support.
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.