On this page
Walker_PageDropdown::start_el( string $output, WP_Post $data_object, int $depth, array $args = array(), int $current_object_id )
Starts the element output.
Description
See also
Parameters
$outputstring Required-
Used to append additional content. Passed by reference.
$data_objectWP_Post Required-
Page data object.
$depthint Optional-
Depth of page in reference to parent pages.
Used for padding. Default 0. $argsarray Optional-
Uses
'selected'argument for selected page to set selected HTML attribute for option element. Uses'value_field'argument to fill "value" attribute.
See wp_dropdown_pages() .More Arguments from wp_dropdown_pages( ... $args )
Array or string of arguments to retrieve pages.
child_ofintPage ID to return child and grandchild pages of. Note: The value of$hierarchicalhas no bearing on whether$child_ofreturns hierarchical results. Default 0, or no restriction.sort_orderstringHow to sort retrieved pages. Accepts'ASC','DESC'. Default'ASC'.sort_columnstringWhat columns to sort pages by, comma-separated. Accepts'post_author','post_date','post_title','post_name','post_modified','menu_order','post_modified_gmt','post_parent','ID','rand','comment*count'.
'post*'can be omitted for any values that start with it.
Default'post_title'.hierarchicalboolWhether to return pages hierarchically. If false in conjunction with$child_ofalso being false, both arguments will be disregarded.
Default true.excludeint[]Array of page IDs to exclude.includeint[]Array of page IDs to include. Cannot be used with$child_of,$parent,$exclude,$meta_key,$meta_value, or$hierarchical.
meta_keystringOnly include pages with this meta key.meta_valuestringOnly include pages with this meta value. Requires$meta_key.
authorsstringA comma-separated list of author IDs.parentintPage ID to return direct children of. Default -1, or no restriction.exclude_treestring|int[]Comma-separated string or array of page IDs to exclude.
numberintThe number of pages to return. Default 0, or all pages.offsetintThe number of pages to skip before returning. Requires$number.
Default 0.post_typestringThe post type to query. Default'page'.post_statusstring|arrayA comma-separated list or array of post statuses to include.
Default'publish'.
Default:
array() $current_object_idint Optional-
ID of the current page. Default 0.
Source
File: wp-includes/class-walker-page-dropdown.php. View all references
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.
$page = $data_object;
$pad = str_repeat( ' ', $depth * 3 );
if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) {
$args['value_field'] = 'ID';
}
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . '"';
if ( $page->ID == $args['selected'] ) {
$output .= ' selected="selected"';
}
$output .= '>';
$title = $page->post_title;
if ( '' === $title ) {
/* translators: %d: ID of a post. */
$title = sprintf( __( '#%d (no title)' ), $page->ID );
}
/**
* Filters the page title when creating an HTML drop-down list of pages.
*
* @since 3.1.0
*
* @param string $title Page title.
* @param WP_Post $page Page data object.
*/
$title = apply_filters( 'list_pages', $title, $page );
$output .= $pad . esc_html( $title );
$output .= "</option>\n";
}
Hooks
- apply_filters( 'list_pages',
string $title ,WP_Post $page ) -
Filters the page title when creating an HTML drop-down list of pages.
Related
Uses
| Uses | Description |
|---|---|
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| esc_html() wp-includes/formatting.php | Escaping for HTML blocks. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/walker_pagedropdown/start_el