Advertisements

wp_dropdown_pages

Definition:
function wp_dropdown_pages($args = '') {}

Retrieve or display list of pages as a dropdown (select list).

Parameters

  • array|string $args: Optional. Override default arguments.

Return values

returns:HTML content, if not displaying.

Defined filters

  • wp_dropdown_pages
    apply_filters('wp_dropdown_pages', $output)

Source code

function wp_dropdown_pages($args = '') {

	$defaults = array(

		'depth' => 0, 'child_of' => 0,

		'selected' => 0, 'echo' => 1,

		'name' => 'page_id', 'id' => '',

		'show_option_none' => '', 'show_option_no_change' => '',

		'option_none_value' => ''

	);



	$r = wp_parse_args( $args, $defaults );

	extract( $r, EXTR_SKIP );



	$pages = get_pages($r);

	$output = '';

	// Back-compat with old system where both id and name were based on $name argument

	if ( empty($id) )

		$id = $name;



	if ( ! empty($pages) ) {

		$output = "<select name='" . esc_attr( $name ) . "' id='" . esc_attr( $id ) . "'>\n";

		if ( $show_option_no_change )

			$output .= "\t<option value=\"-1\">$show_option_no_change</option>";

		if ( $show_option_none )

			$output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">$show_option_none</option>\n";

		$output .= walk_page_dropdown_tree($pages, $depth, $r);

		$output .= "</select>\n";

	}



	$output = apply_filters('wp_dropdown_pages', $output);



	if ( $echo )

		echo $output;



	return $output;

}

3615

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: