Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to pull a custom post type name/title out for use in the breadcrumb of a single-[cpt].php template file.

In the archive-[cpt].php I can use post_type_archive_title() and it echo the name. How would I get this same title in a single view?

Thanks!

I've trawled though the codex and haven't seen a function, but might have missed it!

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

There doesn't appear to be one, but the following should work:

   //Get post type    
   $post_type_obj = get_post_type_object('my-cpt');
   //Get post type's label
   $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );

But I can't see why you shouldn't simply hard-code the title inside single-[cpt].php, since its custom post type specific...

share|improve this answer
    
Thanks for the suggestion Stephen, yes I know it seems like i should be able to just enter the name manually, but I wanted this template to work across the board for other CPT's too, I should have said that first. Also your solution is still probably what I'll use because it'll pull out the Label so if that ever changes the breadcrumb will reflect that change. –  Mere Development Feb 1 '12 at 21:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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