• Hi, how can I change labels in the admin section. For example, instead of “Add a Post” I want it to say “Add an event”. I can do this by changing a file in the wp-admin folder, but I’d rather do this in functions.php so I don’t screw anything up if I upgrade.
    Actually, I have a lot of customizing to do in the back end. Are there any guidelines/tutorials available? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Well, I’ve managed to do this by re-registering ‘Post’ type with custom labels with an init hook. Like this:

    add_action('init','test_custom_post');
    function test_custom_post()
    {
    	$labels = array(
        'name' => _x('Books', 'post type general name'),
        'singular_name' => _x('Book', 'post type singular name'),
        'add_new' => _x('Add New', 'book'),
        'add_new_item' => __('Add New Book'),
        'edit_item' => __('Edit Book'),
        'new_item' => __('New Book'),
        'view_item' => __('View Book'),
        'search_items' => __('Search Books'),
        'not_found' =>  __('No books found'),
        'not_found_in_trash' => __('No books found in Trash'),
        'parent_item_colon' => ''
      );
    
    register_post_type( 'post', array(
    			'labels' => $labels,
               'public'  => true,
              '_builtin' => true,
              '_edit_link' => 'post.php?post=%d',
               'capability_type' => 'post',
                'hierarchical' => false,
               'rewrite' => false,
                'query_var' => false,
               'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions' ),
           ) );
    }

    To change the admin tab menu labels you have to hackishly hook to a filter in the wp-admin/post.php file:

    add_filter('menu_order','change_label');
    function change_label($stuff)
    {
    	global $menu,$submenu;
    
    	$menu[5][0]= 'Books';
    	$submenu['edit.php'][5][0]  = 'Books';
    return $stuff;
    }

    I wouldn’t count on it though, as the register_post_type function comment for ‘_builtin’ argument clearly says ‘THIS IS FOR INTERNAL USE ONLY!’, although after a quick glance on the code looks like it just overwrites the default defined post type – at least on WP 3.0.

    Uh, missed something. In order for above code to work, you also have to add filter for a ‘custom_menu_order’:

    add_filter('custom_menu_order','order');
    function order()
    {
    	return true;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change labels in admin section’ is closed to new replies.