Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Maja B.
Maja B.
12,984 Points

Display the Label of a custom post type

Hi, is there a way to display a label of a custom post type.

For example: Custom post type: movie Label: Movies

I would like to display the Lable on the singular-movie.php page. At the top of the page so that it would work like a kind of breadcrumb.

So is there a function to display it. Something like the_title()

Raymon Oleaga
Raymon Oleaga
19,298 Points

Hi,

try: <?php post_type_archive_title(); ?>

also check this linkout: http://codex.wordpress.org/Function_Reference/post_type_archive_title#Description

also might work:

< ?php $post_type = get_post_type_object( get_post_type($post) );

echo $post_type->label ; ?>
Maja B.
Maja B.
12,984 Points

Hi, Thanks. That works perfectly! Do you maybe know how to make it translatable. That's probably not so easy.

P.S. I cannot give you a best answer (no button for that). The reason could be that you've clicked Add comment, instead of Add answer ...

1 Answer

Raymon Oleaga
Raymon Oleaga
19,298 Points

I am glad it helped :)

translatable as in to translate to another language?


Oh, I see about the comment / answer thingy...

Well here is your answer again! haha. Have a great day!

try: <?php post_type_archive_title(); ?>

also check this linkout: http://codex.wordpress.org/Function_Reference/post_type_archive_title#Description

also might work:

< ?php $post_type = get_post_type_object( get_post_type($post) );

echo $post_type->label ; ?>