I was looking to get more info about 'singular_name' label and came across this link. Based on that link 'singular_name' value should show up when I click 'Add New' and 'Add New Post' window appears. My understanding the value would replace the 'Post' part in the 'Add New Post' title. It's not working for me.
My code
function portfolio_register() {
$labels = array (
'name' => __('Portfolio'),
'singular_name' => __('Project'),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_ui'=> true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('portfolio', $args);
}
add_action ('init', 'portfolio_register');
I was able to achive the desired effect using 'add_new' and 'add_new_item' labels, however, was just curious what is the purpose of 'singular_name' label.
I was looking to get more info about 'singular_name' label and came across this link. Based on that link 'singular_name' value should show up when I click 'Add New' and 'Add New Post' window appears. My understanding the value would replace the 'Post' part in the 'Add New Post' title. It's not working for me.
My code
function portfolio_register() {
$labels = array (
'name' => __('Portfolio'),
'singular_name' => __('Project'),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_ui'=> true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('portfolio', $args);
}
add_action ('init', 'portfolio_register');
I was able to achive the desired effect using 'add_new' and 'add_new_item' labels, however, was just curious what is the purpose of 'singular_name' label.
Share Improve this question asked Apr 21, 2020 at 4:08 810311810311 417 bronze badges1 Answer
Reset to default 1The answer at that link is incorrect.
The "Edit Animals" text from their answer uses the edit_item
label, not singular_name
. There's a much longer list of labels that you'll need to provide when registering a post type than just those two. The full list is kept here.
As for singular_name
, as far as I can tell, this is only used to label menu items and link suggestions:
In both those examples "Page" is where the singular_name
is used.