WordPress at a glance
function is not described

Walker::get_number_of_root_elements() public WP 2.7.0

Calculates the total number of root elements.

{} It's a method of the class: Walker{}

No Hooks.

Return

Int. Number of root elements.

Usage

$Walker = new Walker();
$Walker->get_number_of_root_elements( $elements );
$elements(array) (required)
Elements to list.

Changelog

Since 2.7.0 Introduced.

Code of Walker::get_number_of_root_elements() WP 5.7.2

<?php
public function get_number_of_root_elements( $elements ) {
	$num          = 0;
	$parent_field = $this->db_fields['parent'];

	foreach ( $elements as $e ) {
		if ( 0 == $e->$parent_field ) {
			$num++;
		}
	}
	return $num;
}