Setting Post Type Labels in WordPress

In WordPress when creating or generating a custom post type, for your post type several text strings are shown throughout the WordPress admin dashboard. Text strings are typically a button, link, or extra information about the post type in WordPress.In the WordPress by default, the term “page” for hierarchical post types and the “post” is used for non-hierarchical post types. Let’s suppose in previous article http://www.webdirectors.co.uk/register-custom-post-types-wordpress-web-designer-london/ you use the basic custom post type registration code, Did you noticed that the text “Add New Post” at the top of the page appear when you add a new Product in admin panel. Behind the reason is that this Product is a post of type Product.

Actually this isn’t very perfect; actually you aren’t adding a post, but rather a new Product. The labels argument setting when you registering your custom post type in WordPress will allow you to define exactly what is shown in the post.
For custom posts type the available labels see below:

  •  name — For the post type the name generally plural, In the wordpress this is used by the admin or themes and plugins.
  • singular_name — For the post type the singular version of the name. It used in the WordPress by the admin and by other themes and plugins.
  • add_new — It use the label for the Add New in submenu item. This by default text is “Add New.”
  • add_new_item — This is used as the header text on the main post listing page to add a new post. The By default text is, “Add New Post/Page.”
  •  edit_item — This is used as the text for editing an individual post in admin panel. The default text is “Edit Post/Page.”
  •  new_item — This is use for creating a new post. “New Post/Page.” The text is by default like that.
  •  view_item — This is use text for viewing an single post entry that have saved. The default text is “View Post/Page.”
  •  search_items — This is use for text displayed for searching the posts of this type which is saved. The default text is “Search Posts/Pages.”
  •  not_found — This text shown when no posts were found in a search made by you. The text by default, it displays “No posts/pages found.”
  •  not_found_in_trash — This text shown when no posts are in the trash file. “No posts/pages found in Trash.” By default this text will show.
  •  parent_item_colon — This text shown when displaying a post’s parent. Only used this text

with the classified post types and it displays by default “Parent Page:”. When administering a WordPress website then the setting of each value it makes you for a much better user experience. Below the following code, Very big changing by you, you’ve set the labels for the Product post type and modified your original custom post type registration code:

<?php
add_action( ‘init’, ‘register_my_post_types_for_webagency’ );
function register_my_post_types_for_webagency () {
$labels = array(
‘name’ => ‘Products’,
‘singular_name’ => ‘Product’,
‘add_new’ => ‘Add New Product’,
‘add_new_item’ => ‘Add New Product’,
‘edit_item’ => ‘Edit Product’,
‘new_item’ => ‘New Product’,
‘all_items’ => ‘All Products’,
‘view_item’ => ‘View Product’,
‘search_items’ => ‘Search Products’,
‘not_found’ => ‘No products found’,
‘not_found_in_trash’ => ‘There is no products found in Trash’,
‘parent_item_colon’ => ”,
‘menu_name’ => ‘Products’
);
$args = array(
‘labels’ => $labels,
‘public’ => true
);
register_post_type( ‘products’, $args );
}
?>