Created
June 17, 2013 15:26
-
-
Save ataylorme/5797774 to your computer and use it in GitHub Desktop.
Adds a page select field to Custom Metaboxes and Fields for WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ADD PAGE SELECT FIELD */ | |
function metabox_page_select_field( $field, $meta ) { | |
$args = array( | |
'depth' => 0, | |
'child_of' => 0, | |
'selected' => $meta, | |
'echo' => 1, | |
'name' => $field['id'] | |
); | |
wp_dropdown_pages($args); | |
echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; | |
}//end metabox_page_select_field | |
add_action( 'cmb_render_page_select', 'metabox_page_select_field', 10, 2 ); | |
function metabox_page_select_field_validate( $new ) { | |
if ( !is_numeric( $new ) ) {$new = "";} | |
return $new; | |
}//end metabox_page_select_field_validate | |
add_filter( 'cmb_validate_page_select', 'metabox_page_select_field_validate' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment