Php 多选值保存问题
我制作了元框,在这个框中,我用多个Php 多选值保存问题,php,wordpress,save,meta,Php,Wordpress,Save,Meta,我制作了元框,在这个框中,我用多个 $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'
$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>
$\u POST['opt\u meta\u author'])
的var转储是什么?如果它是一个数组,则使用内爆
将其转换为字符串,并将字符串保存在数据库中无任何变化,它只给出了这个-s:6:“Nadeem”@deemi.exe如果选择多个,则它将作为数组传递给服务器,并且在保存到数据库之前必须序列化。我执行此操作$opt_meta_author=serialize($\u POST['opt_meta_author']);更新帖子元($post->ID,$opt\u meta\u author',$opt\u meta\u author);当我用多个选择值保存时,它只给我一个值这是一个字符串,你能告诉我如何在dbI guessupdate\u post\u meta($post->ID,'opt\u meta\u author',$opt\u meta\u author)中保存吗代码>应该在数据库中进行保存。我使用过很多人的内爆和它的工作,但我犯的一个错误是,使用内爆()做这件事和它的工作都很好
$opt_meta_author = $_POST['opt_meta_author'];
update_post_meta( $post->ID, 'opt_meta_author', $opt_meta_author);
$opt_meta_author = unserialize(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>
$opt_meta_author = serialize($_POST['opt_meta_author']);