You are wrong, your custom field is saved but you won’t see the value pre-selected in the select box. To see it you have to set the selected
attribute of the select
element. You can do it easily with selected()
function. You should also escape the attribute values and, in your case, use wp_reset_postdata
instead of wp_reset_query
:
if($my_custom_query->have_posts()) : ?>
<select name="news_one" id="news_one">
<?php while($my_custom_query->have_posts()) :
$my_custom_query->the_post();
$title = get_the_title();
?>
<option value="<?php esc_attr_e($title); ?>" <?php selected( $text_field_one, $title ); ?>><?php echo $title; ?></option>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>