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

<?php $post_type = get_post_type( $post->ID ); if $post_type == 'project' : echo 'Work'; ?>

How can I make the above work? I want it so that if the post type is 'projects', then it echoes 'Work'.

Also, I want to add another if post type is 'movies' then it echoes 'Film' on top of that.

share|improve this question
Maybe this is just a typo here, but in one place you say the post type is project and in another place you say projects. If it's projects and you're saying if $post_type == 'project' then it's not going to work – eileencodes Mar 14 '11 at 18:11
up vote 1 down vote accepted

Well, as far as I can tell you've got a syntax error there. Try this:

<?php $post_type = get_post_type( $post->ID ); if ($post_type == 'project') echo 'Work'; ?>

Also, make sure to check out what eileen.carpenter said in the comment to your question.

share|improve this answer

Why not use native labels that you set up for custom post type?

$post_type = get_post_type_object($post->post_type);
echo $post_type->labels->singular_name;
share|improve this answer

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.