Skip to content

Instantly share code, notes, and snippets.

@niksudan
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niksudan/1b2d980559331f357e36 to your computer and use it in GitHub Desktop.
Save niksudan/1b2d980559331f357e36 to your computer and use it in GitHub Desktop.
Assign custom post type labels quickly [WordPress]
<?php
/**
* Assign custom post type labels quickly
*
* @param string $singular
* @param string $plural
* @return array
*/
function register_post_type_labels( $singular, $plural = NULL )
{
$plural = $plural == NULL ? $singular . 's' : $plural;
return array(
'name' => $plural,
'singular_name' => $singular,
'add_new' => 'Add New ' . $singular,
'add_new_item' => 'Add New ' . $singular,
'edit_item' => 'Edit ' . $singular,
'new_item' => 'New ' . $singular,
'view_item' => 'View ' . $singular,
'search_items' => 'Search ' . $plural,
'not_found' => 'No ' . $plural . ' found',
'not_found_in_trash' => 'No ' . $plural .' found in Trash',
'parent_item_colon' => 'Parent '. $singular . ':',
'menu_name' => $plural,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment