admin管理员组

文章数量:1289581

I created custom-post-type.php file in folder of mu-plugins:

    <?php 

function custom_post_types(){
    register_post_type('event', array(
        'public' => true,
        'labels' => array(
            'name' => 'Events',
            'edit_item'=>'Edit Event',
            'edit_posts' => 'Add New Event',
            'all_items' => 'All Events'
        ),
        'menu_icon' => 'dashicons-calendar'
    ));
  }
  
  add_action('init', 'custom_post_types');

These two labels name of 'edit_item'=> 'Edit Event', & 'edit_posts' => 'Add New Event' not working. I wanted to know where i am mistaken. Can somebody help? Thank you!

I created custom-post-type.php file in folder of mu-plugins:

    <?php 

function custom_post_types(){
    register_post_type('event', array(
        'public' => true,
        'labels' => array(
            'name' => 'Events',
            'edit_item'=>'Edit Event',
            'edit_posts' => 'Add New Event',
            'all_items' => 'All Events'
        ),
        'menu_icon' => 'dashicons-calendar'
    ));
  }
  
  add_action('init', 'custom_post_types');

These two labels name of 'edit_item'=> 'Edit Event', & 'edit_posts' => 'Add New Event' not working. I wanted to know where i am mistaken. Can somebody help? Thank you!

Share Improve this question edited Jul 27, 2021 at 20:52 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jul 27, 2021 at 19:48 WardaWarda 1055 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2
  1. You have put these labels inside the capabilities argument, which is incorrect. They should be in labels argument.
  2. There is not edit_posts label, and you're missing most labels. There's many more labels you need to provide. They are listed here: https://developer.wordpress/reference/functions/get_post_type_labels/

本文标签: Custom Post type Labels are not showing