How to Display Custom Post Type Titles and Labels with Shortcodes
Content
Many WordPress users who create custom post types with the Custom Post Type UI plugin eventually need to display those post type names or labels on their website. Whether you want to show "Movies" above your movie listings or indicate which post type a search result comes from, this is a common requirement that isn't built directly into the plugin.
Why This Happens
The Custom Post Type UI plugin focuses exclusively on registering and managing custom post types in WordPress. It doesn't include frontend display functionality like shortcodes for showing post type names or labels. This is by design - the plugin handles the backend registration while themes and other plugins typically handle display.
The Solution: Create Your Own Shortcode
Based on community solutions from the BugWP forums, here's how you can create a shortcode to display your custom post type labels anywhere on your site:
add_shortcode( 'post_type_title', 'custom_post_type_title_shortcode' );
function custom_post_type_title_shortcode( $atts ) {
$atts = shortcode_atts( [
'post_type' => '',
], $atts );
if ( empty( $atts['post_type'] ) ) {
return '';
}
$obj = get_post_type_object( $atts['post_type'] );
return $obj->label;
}
How to Use This Shortcode
Once you've added this code to your theme's functions.php file or a custom plugin, you can use the shortcode in several ways:
- Basic usage:
[post_type_title post_type="movies"]- displays "Movies" - In templates:
<?php echo do_shortcode( '[post_type_title post_type="fruits"]' ); ?> - In widgets: Simply paste the shortcode into any text widget
Alternative Approaches
If you need more complex displays, consider these alternatives:
- Custom PHP in templates: Use
get_post_type_object()directly in your theme files - Page builders: Many builders like Elementor or Oxygen have dynamic data capabilities that can display post type information
- Archive titles: For archive pages, your theme should automatically display the post type label
Important Notes
Remember that display issues are often theme-related. If you're having trouble with titles showing or hiding, check your theme settings first. The Custom Post Type UI team focuses on post type registration rather than frontend display, so most visual customization needs to be handled through your theme or custom code.
This solution has been tested by the BugWP community and provides a reliable way to display your custom post type labels without additional plugins.
Related Support Threads Support
-
How to show items lists on a page?https://wordpress.org/support/topic/how-to-show-items-lists-on-a-page/
-
Title shortcodehttps://wordpress.org/support/topic/title-shortcode-2/
-
add shortcode in archive setting title in CTPhttps://wordpress.org/support/topic/add-shortcode-in-archive-setting-title-in-ctp/
-
I want to show through a shortcode the categories of a posthttps://wordpress.org/support/topic/i-want-to-show-through-a-shortcode-the-categories-of-a-post/
-
Get Grandparent’s Titlehttps://wordpress.org/support/topic/get-grandparents-title/
-
Stop title from displaying on CPTshttps://wordpress.org/support/topic/stop-title-from-displaying-on-cpts/
-
Hide Headerhttps://wordpress.org/support/topic/hide-header-6/
-
Set number of posts in shortcodehttps://wordpress.org/support/topic/set-number-of-posts-in-shortcode/
-
How to call the rewrite slug in an Oxygen templatehttps://wordpress.org/support/topic/how-to-call-the-rewrite-slug-in-an-oxygen-template/
-
Displaying custom post types in widgethttps://wordpress.org/support/topic/displaying-custom-post-types-in-widget/
-
Make shortcode to display post type’s name/labelhttps://wordpress.org/support/topic/make-shortcode-to-display-post-types-name-label/
-
Shortcode for custom post type titlehttps://wordpress.org/support/topic/shortcode-for-custom-post-type-title/
-
welcome to my website showinghttps://wordpress.org/support/topic/welcome-to-my-website-showing/