• First of all this is my code…

    register_post_type('professor', 
                                array(  'public'=>true,
                                        'has_archive'=>true,
                                        'menu_icon'=>'dashicons-welcome-learn-more',
                                        'supports'=>array('title','editor','comments','author','excerpt'),
                                        'rewrite'=>array('slug'=>'professors'),
                                        'labels'=>array('name'=>'Professors',
                                                        'add_new'=>'Add Professor',
                                                        'edit_item'=>'Edit Professor',
                                                        'new_item'=>'Add New Professor',
                                                        'add_new_item'=>'Add New Professors'
                                                        )
                                    )
            );

    Regarding ‘add_new’ this is what will appear in the editor menu but in the documentation it doesn’t give any indication what this is what will appear in the editors left hand menu.
    Both new_item & add_new_item are described as labels but I don’t understand the difference between them:
    add_new_item‘ – Label for adding a new singular item. Default is ‘Add New Post’ / ‘Add New Page’.
    new_item‘ – Label for the new item page title. Default is ‘New Post’ / ‘New Page’.

    I’ve assigned a label to both as you can see in my code but don’t see ‘new_item’ label anywhere. Again I feel this is badly explained and confusing. Could someone explain the difference please.

    • This topic was modified 6 years, 9 months ago by GusGF.
    • This topic was modified 6 years, 9 months ago by GusGF.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • OK, this should probably be cleaned up, which means it needs a Trac ticket with the docs keyword. (search for it first)
    https://core.trac.ww.wp.xz.cn/

    Part of the confusion is that the block editor uses the labels differently than the Classic editor did. The label is not visible, but is there for screen reader apps.

    I tried it with a plugin (CPT UI) and the descriptions there are slightly better, but still not right.

    add_new is used in the menu and in the list page on the button.
    add_new_item is used as the page title of the Classic editor and screen-reader-text in block editor.
    new_item is the one I can’t see anywhere or find in a search of the code.

Viewing 1 replies (of 1 total)

The topic ‘Page labels poorly explained in docs’ is closed to new replies.