← Ta mig hem

Archive for December, 2011

Custom Post Type Labels, bättre formatterade

Wednesday, 21 December, 2011 - Inga kommentarer

När man lägger till nya post-typer i ett WordPress-tema eller plugin har man möjlighet att ändra texter som visas i admin-gränssnittet. Man kan även använda localization med dessa. Det här är bara ett template för att enkelt copy-pastea in alla labels och snabbt komma igång med att ändra deras värde.

$labels = array(
 'name' => __('', 'domain'), // - general name for the post type, usually plural. The same as, and overridden by $post_type_object->label
 'singular_name' => __('', 'domain'), // - name for one object of this post type. Defaults to value of name
 'add_new' => _x('', 'domain'), // - the add new text. The default is Add New for both hierarchical and non-hierarchical types.
 // - When internationalizing this string, please use a gettext context matching your post type. Example: _x('Add New', 'product');
 'all_items' => __('', 'domain'), // - the all items text used in the menu. Default is the Name label
 'add_new_item' => __('', 'domain'), // - the add new item text. Default is Add New Post/Add New Page
 'edit_item' => __('', 'domain'), // - the edit item text. Default is Edit Post/Edit Page
 'new_item' => __('', 'domain'), // - the new item text. Default is New Post/New Page
 'view_item' => __('', 'domain'), // - the view item text. Default is View Post/View Page
 'search_items' => __('', 'domain'), // - the search items text. Default is Search Posts/Search Pages
 'not_found' => __('', 'domain'), // - the not found text. Default is No posts found/No pages found
 'not_found_in_trash' => __('', 'domain'), // - the not found in trash text. Default is No posts found in Trash/No pages found in Trash
 'parent_item_colon' => __('', 'domain'), // - the parent text. This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page
 'menu_name' => __('', 'domain') // - the menu name text. This string is the name to give menu items. Defaults to value of name
 );