Hi i was wondering if there is a way that i can display the custom post type title.

For example:

I have a custom post type entitled "Pretty Little Liars" and it also shows on the homepage, but how do i get the POST TYPE title, not the title of the post to show up like a category.

For example:

Plublished in: Pretty Little Liars

is this possible?

Also i want it to link to the post type page

  • You got a custom post type, that's registered with the name of "Pretty Little Liars"?
    – kaiser
    Commented Jul 31, 2012 at 10:52
  • Yes i do, I'm opening a blog thats all about TV shows, can you help me? Commented Jul 31, 2012 at 11:04
  • Already answered, but honestly: Why not simply add taxonomies for the different shows?
    – kaiser
    Commented Jul 31, 2012 at 11:10
  • I wanted to add Post types because each post type page will have a design to fit it :) Commented Jul 31, 2012 at 11:13
  • 1
    You could conditionally switch templates. Or stylesheets. Or just append the class of the current taxonomy (see body_class() and post_class()) to your rules...
    – kaiser
    Commented Jul 31, 2012 at 11:26

2 Answers 2


You can write a general template tag for this task.

function wpse60306_get_post_type( $echo = true )
    static $post_types, $labels = '';

    // Get all post type *names*, that are shown in the admin menu
    empty( $post_types ) AND $post_types = get_post_types( 
            'show_in_menu' => true,
            '_builtin'     => false,

    empty( $labels ) AND $labels = wp_list_pluck( $post_types, 'labels' );
    $names = wp_list_pluck( $labels, 'singular_name' );
    $name = $names[ get_post_type() ];

    // return or print?
    return $echo ? print $name : $name;


We got two variables declared as static, so we don't have to redo the task, if you're for example using it inside a loop that shows posts from different post types.

You also got an argument ((bool) true/false) to switch if you just want to return or right print the name.

This function doesn't work for built in post types (assuming you don't need it). If you need it for built in post types too, then just remove the _builtin argument from the function inside ↑ get_post_types().

  • 1
    Hey Thank you very much Kaiser, but i just found a more simple solution, using this code <?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->label ; ?> It shows the post type name but the only problem is, i don't know how to get it to link to the post type page, can you help me with that one please? Commented Jul 31, 2012 at 11:14
  • First: Don't mess with objects, until you really know what you're doing. The public API (a.k.a. "Template Tags") have a reason why they exist. If you don't want that the sky falls on your head with an update, then use what ↑ I recommended/wrote for you. Second: It should be as simple as using the the_permalink() Template Tag.
    – kaiser
    Commented Jul 31, 2012 at 11:27
  • 1
    So your code is calling all the post type titles right? and if so how do i get them to display on the homepage, on a post that's associated with the post type Commented Jul 31, 2012 at 11:31
  • Simply add wpse60306_get_post_type() in your loop.
    – kaiser
    Commented Jul 31, 2012 at 11:49
  • Thank you very much Kaiser :) I'm hoping to launch the site in mid august Tv-Cafe.com Commented Jul 31, 2012 at 11:52

Just in case someone is looking for further answers here, there is a builtin wordpress function:


its there since 2011, reference: https://developer.wordpress.org/reference/functions/post_type_archive_title/, old reference: https://codex.wordpress.org/Function_Reference/post_type_archive_title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.