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.

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

2 Answers

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

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
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.