wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
parent_dropdown › WordPress Function
Seit1.5.0
Veraltetn/v
› parent_dropdown ( $default_page = 0, $parent_page = 0, $level = 0, $post = null )
Parameter: (4) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: | |
Changelog: |
|
Prints out option HTML elements for the page parents drop-down.
Ähnliche Funktionen: page_template_dropdown, wp_dropdown_cats, wp_dropdown_users, wp_dropdown_roles, wp_dropdown_pages
Quellcode
function parent_dropdown( $default_page = 0, $parent_page = 0, $level = 0, $post = null ) { global $wpdb; $post = get_post( $post ); $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_page ) ); if ( $items ) { foreach ( $items as $item ) { // A page cannot be its own parent. if ( $post && $post->ID && (int) $item->ID === $post->ID ) { continue; } $pad = str_repeat( ' ', $level * 3 ); $selected = selected( $default_page, $item->ID, false ); echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html( $item->post_title ) . '</option>'; parent_dropdown( $default_page, $item->ID, $level + 1 ); } } else { return false; } }