我成功地将所有帖子类型都添加到了选择中 选择帖子类型
<select name="meta-select" id="select_post_types" class="form-control">
<?php foreach ( $post_types as $post_type ) { ?>
<option value="<?php print $post_type; ?>"> <?php print $post_type; ?> </option>
<?php } ?>
</select>
但是,当管理员从顶部选择中选择时,我想填充所有选定帖子类型的帖子。
遵循第二个选择
<select name="meta-select" id="select_post" class="form-control">
<option value=""> </option>';
</select>
答案 0 :(得分:0)
<?php
$args = array(
'public' => true,
'_builtin' => false
);
$output = 'names'; // names or objects, note names is the default
$operator = 'and'; // 'and' or 'or'
$post_types = get_post_types( $args, $output, $operator );
?>
<select name="meta-select" id="select_post" class="form-control">
<?php
foreach ( $post_types as $post_type ) {
?>
<option value="<?php print $post_type; ?>"> <?php print $post_type; ?> </option>
<?php
}
?>
</select>