Custom Post Type dropdown not saving values
-
Hi I’m using a custom post type and my values are saving to the database correctly, but the dropdown box is not holding those valued after the update from the user. Here is the function that contains the dropdown
`// The Callback for Page Template Assignmets Metabox
function pagetemplate() {
global $post;
// Noncename needed to verify where the data originated
echo ‘<input type=”hidden” name=”pagetemplatemeta_noncename” id=”pagetemplatemeta_noncename” value=”‘ .
wp_create_nonce( plugin_basename(__FILE__) ) . ‘” />’;
// Get the title data if its already been entered$template = !empty($post->page_template) ? $post->page_template : false;
?>
<label class=”screen-reader-text” for=”page_template”><?php _e(‘Page Template’) ?></label>
<select name=”page_template” id=”page_template”>
<option value=’default’><?php _e(‘Default Template’); ?></option>
<?php template_dropdown($template); ?>
</select><?php
}
function template_dropdown( $default = ” ) {
$templates = get_page_templates();
ksort( $templates );
foreach (array_keys( $templates ) as $template )
: if ( $default == $templates[$template] )
$selected = ” selected=’selected'”;
else
$selected = ”;
echo “\n\t<option value='”.$templates[$template].”‘ $selected>$template</option>”;
endforeach;
}’
- The topic ‘Custom Post Type dropdown not saving values’ is closed to new replies.