Starts the element output.
$outputstringrequired
$data_objectWP_Postrequired
$depthintoptional
$argsarrayoptional
'selected' argument for selected page to set selected HTML attribute for option element. Uses 'value_field' argument to fill "value" attribute.child_of int$hierarchical has no bearing on whether $child_of returns hierarchical results. Default 0, or no restriction.sort_order string'ASC', 'DESC'. Default 'ASC'.sort_column string'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.'post_title'.hierarchical bool$child_of also being false, both arguments will be disregarded.exclude int[]include int[]$child_of, $parent, $exclude, $meta_key, $meta_value, or $hierarchical.meta_key stringmeta_value string$meta_key.authors stringparent intexclude_tree string|int[]number intoffset int$number.post_type string'page'.post_status string|array'publish'.Default:array()
$current_object_idintoptional
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 === (int) $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";
}
Filters the page title when creating an HTML drop-down list of pages.
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/walker_pagedropdown/start_el