我的自定义元框有一个下拉字段,但如何将默认选项值设置为空?它目前正在通过CPT的meta\\u值进行填充,但我希望这有所改变。
以下是该问题的截图:
我希望第二作者字段的第一个选项为空/没有选择。
元框代码:
case \'select\' :
$author_select_query = new WP_Query(array(
\'post_type\' => \'people\',
\'tax_query\' => array(
\'relation\' => \'OR\',
array(
\'taxonomy\' => \'role\',
\'field\' => \'slug\',
\'terms\' => array(\'adjunct-faculty\'),
),
array(
\'taxonomy\' => \'role\',
\'field\' => \'slug\',
\'terms\' => array(\'faculty\'),
)
),
\'meta_key\' => \'ecpt_people_alpha\',
\'orderby\' => \'meta_value\',
\'order\' => \'ASC\',
\'posts_per_page\' => \'-1\'));
$authors = $author_select_query ->get_posts();
echo \'<select name="\', $field[\'id\'], \'" id="\', $field[\'id\'], \'">\';
foreach($authors as $author) {
echo \'<option value="\' . $author->ID . \'"\', $meta == $author->ID ? \' selected="selected"\' : \'\', \'>\', $author->post_title, \'</option>\';
}
echo \'</select>\';