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'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
add comment

1 Answer 1

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!):

<?php
/*
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
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.