嘿,我正在尝试创建一个select选项,类似于Alecaddd的本教程,我一直在关注Alecadd Gibhub。我尝试用下面的代码输出一个select选项,它显示了,但没有保存所选的选项。
function sa_comments_callback(){
$options = get_option( 'postpage_comments' );
$comments = array( 'Post', 'Page', 'Both', 'None' );
$output = '<select name="">';
foreach( $comments as $comment ){
$output .= '<option id="' . $comment . '" value="' . $comment . '"' . selected( @$options[$comment] ) . '">' . $comment . '</option>';
}
$output .= '</select>';
echo $output;
}
任何帮助都将不胜感激。
发布于 2016-08-30 23:14:19
您在哪里使用update_option?据我所知,代码应该可以工作。还要尝试在selected函数中添加一些默认值
https://stackoverflow.com/questions/39227389
复制相似问题