i make meta box and in this i make select option with multiple
$opt_meta_author = get_post_meta($post->ID, 'opt_meta_author', true);
<select name="opt_meta_author" id="opt_meta_author" multiple="multiple">
<?php
$auth_args = array(
'post_type' => 'author',
'orderby' => 'title',
'order' => 'ASC'
);
$authors = new WP_Query($auth_args);
while($authors->have_posts()) :
$authors->the_post();
?>
<option value="<?php echo the_title() ?>">
<?php echo the_title() ?>
</option>
<?php
endwhile;
?>
</select>
when i select multiple options it save only one option, i want to save selected options
is there any suggestions
Saving meta values
$opt_meta_author = $_POST['opt_meta_author'];
update_post_meta( $post->ID, 'opt_meta_author', $opt_meta_author);
To get multiple selected value while storing do this:
What is the
var dump
of$_POST['opt_meta_author'])
? if it is an array, convert it in string usingimplode
and save the string in database