0

I have a custom post type called 'Bookmark'.

When users add a new Bookmark in the Admin, the title of the page is

Add a new Page

Is there a hook (filter) to change this title to

Add a new Bookmark

  • here you'll get your answer wordpress.stackexchange.com/questions/65075/… – maverick Sep 14 '18 at 8:15
  • I have modified the existing custom post type with the help of the above link. If you want it, let me know I can post this as an answer. Currently I don't see that's necessary. – maverick Sep 14 '18 at 8:27
1

When you're registering new post type with register_post_type, you can pass labels parameter (which is an array of labels used for that CPT).

You can customize these labels:

  • 'name' - general name for the post type, usually plural. The same and overridden by $post_type_object->label. Default is Posts/Pages
  • 'singular_name' - name for one object of this post type. Default is Post/Page
  • 'add_new' - the add new text. The default is "Add New" for both hierarchical and non-hierarchical post types. When internationalizing this string, please use a gettext context matching your post type. Example: _x('Add New', 'product');
  • 'add_new_item' - Default is Add New Post/Add New Page.
  • 'edit_item' - Default is Edit Post/Edit Page.
  • 'new_item' - Default is New Post/New Page.
  • 'view_item' - Default is View Post/View Page.
  • 'view_items' - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
  • 'search_items' - Default is Search Posts/Search Pages.
  • 'not_found' - Default is No posts found/No pages found.
  • 'not_found_in_trash' - Default is No posts found in Trash/No pages found in Trash.
  • 'parent_item_colon' - This string isn't used on non-hierarchical types. In hierarchical ones the default is 'Parent Page:'.
  • 'all_items' - String for the submenu. Default is All Posts/All Pages.
  • 'archives' - String for use with archives in nav menus. Default is Post Archives/Page Archives.
  • 'attributes' - Label for the attributes meta box. Default is 'Post Attributes' / 'Page Attributes'.
  • 'insert_into_item' - String for the media frame button. Default is Insert into post/Insert into page.
  • 'uploaded_to_this_item' - String for the media frame filter. Default is Uploaded to this post/Uploaded to this page.
  • 'featured_image' - Default is Featured Image.
  • 'set_featured_image' - Default is Set featured image.
  • 'remove_featured_image' - Default is Remove featured image.
  • 'use_featured_image' - Default is Use as featured image.
  • 'menu_name' - Default is the same as name.
  • 'filter_items_list' - String for the table views hidden heading.
  • 'items_list_navigation' - String for the table pagination hidden heading.
  • 'items_list' - String for the table hidden heading.
  • 'name_admin_bar' - String for use in New in Admin menu bar. Default is the same as singular_name.

As you can see, add_new_item is the label that should solve your problem.

| improve this answer | |
2

To change the label, add add_new_item in labels array passed when creating your custom post type. Below is an example of custom post type 'Events'.

add_action( 'init', 'create_post_type' );

function create_post_type() {

  register_post_type( 'events',
    array(
        'labels' => array(
            'name' => __( 'Events' ),
            'singular_name' => __( 'Events' ),
            'add_new_item' => __( 'Add Event' ),
            'add_new' => __( 'Add Event' ),
            'edit_item' => __( 'Edit Event' ),
            'featured_image' => __( 'Event Image' ),
            'set_featured_image' => __( 'Upload Event Image' ),
            'remove_featured_image' => __( 'Remove Event Images' ),
            'menu_name' => __( 'Manage Events' ),
        ),
        'public' => true,
        'menu_icon' => 'dashicons-calendar',            
        'has_archive' => true,
        'supports' => array('title', 'thumbnail', 'editor'),
    )
  );
}

For more information about the changing labels in custom post type refer this link

Hope this helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.