Wordpress get custom post type label name
Solution 1
Get the post_type object to get the labels' singular_name
or plural name
,
$post_type_obj = get_post_type_object( 'ice_cream' );
echo $post_type_obj->labels->singular_name; //Ice Cream.
echo $post_type_obj->labels->name; //Ice Creams.
Solution 2
If you are using wordpress custom post type, then you can get required info by following funcitons:
-
Custom post type label
$post_type = get_post_type_object( get_post_type($post) ); $post_type->label
-
Custom field title
$field_name = "ice_cream"; //slug of custom field "Ice Cream" $field = get_field_object($field_name);
so you can use them in your breadcrumb as: $post_type->label / $field['label']
Related videos on Youtube
Abdullah
Hello! I am Mohummad Abdullah, Front End UI/UX Designer & WordPress lover who passionate to create stylish, sleek user experiences & wordpress themes. I use modern technologies to create impactful and engaging experiences for web and mobile devices, which helps seamless brand image across the web.
Updated on September 15, 2022Comments
-
Abdullah over 1 year
I want to echo a custom post type lable/Menu_name.
Example:
I create custom post type named: Product
In product post type I add post Ice Cream.
So I want to echo in ice cream page this example link:
Home/product/Icecream
Basically its like breadcrumb for custom post type.
-
Abdullah almost 12 yearsI am using this plugin but its not showing the custom post type name. It shows: Home > Product Post Title I want: Home > Product (custom Post type) > Post title