WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to show the post type of a post, you can do that with get_post_type(), but in my case the names are not pretty (for ex : p_project_plans). So instead I thought I'd show the asociated "menu_name" (as declared with register_post_type), which looks much nicer (for ex : Project plans).

Is there a way to do that ?

share|improve this question
up vote 2 down vote accepted

Hi @mike23:

This code shows you how to get both singular and plural names (assuming you specified them as such in your register_post_type()).

Note that the code example is presented as a standalone file you can save as test.php file in the root of your website and load in your browser with http://yoursite.com/test.php (assuming you replace yoursite.com with your site's domain!):

Filename: test.php
include( '../wp-load.php' );
header( 'Content-type:text/plain' );

$post_type_object = get_post_type_object('p_project_plans');

echo "Singular: {$post_type_object->labels->singular_name}\n";
echo "Plural: {$post_type_object->labels->name}\n";
share|improve this answer
Thanks a lot MikeSchinkel, that works great. – mike23 Apr 23 '11 at 8:34
@mike23 - Glad I could help! – MikeSchinkel Apr 23 '11 at 20:30

Your Answer


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.