How to show cutom post labels in options?
-
30-10-2019 - |
Question
I have this code:
$args=array(
'public' => true,
'_builtin' => false
);
?>
<select id="<?php echo $this->get_field_id('posttype'); ?>" name="<?php echo $this->get_field_name('posttype'); ?>">
<?php foreach(get_post_types($args,'names') as $post_type) { ?>
<option <?php selected( $instance['posttype'], $post_type ); ?> value="<?php echo $post_type; ?>"><?php echo $post_type; ?></option>
<?php } ?>
</select>
I make custom posts
function my_post_type_interior_articles() {
register_post_type( 'interior_articles',
array(
'label' => __('Interior Design Articles'),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => false,
'menu_position' => 5,
'supports' => array(
'title',
'custom-fields',
'editor',
'excerpt',
'thumbnail')
)
);
}
add_action('init', 'my_post_type_interior_articles');
in dropdown shows "interior_articles", but i need to show "Interior Design Articles"
How to show cutom post labels in options?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange