method_get_hierarchical_page_options()
method_get_hierarchical_page_options( $prepend = [], $append = [] )
Gets a flat array of all pages with hierarchy depth indicators.
Description
Retrieves all pages sorted by menu order and title, then builds a flat associative array where child pages are prefixed with — characters to indicate their depth. Used for breadcrumb parent page selectors in the Method Settings options page.
Parameters
$prepend (array) :
Associative array of options to place before the pages.
$append (array) :
Associative array of options to place after the pages.
Return
(array) Associative array of page_id => '— — Title' with depth prefixes.
Source
File: lib/helper-functions.php
Usage
PHP
$options = method_get_hierarchical_page_options(
array( '' => 'Item is Top Level' ),
array( 'archive_guides' => 'Archive: Guides' )
);
// Returns: [ '' => 'Item is Top Level', 5 => 'About', 12 => '— Our Team', 13 => '— — Leadership', ... ]