I got success in getting all post types in a select Select Post Type
<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>
but I want to populate the posts of all selected post type when admin select from the top select.
Second select is followed
<select name="meta-select" id="select_post" class="form-control">
<option value=""> </option>';
</select>
<?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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.