Advertisements

parent_dropdown

Definition:
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {}

Parameters

  • unknown_type $default
  • unknown_type $parent
  • unknown_type $level

Source code

function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {

	global $wpdb, $post_ID;

	$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );



	if ( $items ) {

		foreach ( $items as $item ) {

			// A page cannot be its own parent.

			if (!empty ( $post_ID ) ) {

				if ( $item->ID == $post_ID ) {

					continue;

				}

			}

			$pad = str_repeat( ' ', $level * 3 );

			if ( $item->ID == $default)

				$current = ' selected="selected"';

			else

				$current = '';



			echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";

			parent_dropdown( $default, $item->ID, $level +1 );

		}

	} else {

		return false;

	}

}

2479

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: