I am using custom post types "listings" and I have a category called "type" and 3 sub cats, "available", "pending", "sold".

I want to display an image/icon on each post in the loop (not the single-listings.php) but the archive view, that corresponds to it's category. Take a look at woothemes' Estate for an example. They have an image over the featured image that says "on show".

Any thoughts on how to go about this? or a plugin that might do something similar?


I found this code reference:

 <?php $cats = get_the_category(); echo $cats[0]->category_name;?>">

And then it said to style using the category as a class in the css, but no go. It returns nothing - wondering if custom post type cats need to be handled differently?

1 Answer 1


You can use the conditional with in_category. http://codex.wordpress.org/Function_Reference/in_category

For example after your loop:

<?php if (in_category('type')) { ?>
                        <img src="<?php echo get_stylesheet_directory_uri();?>/images/custom.gif" alt="" class="customicons"/>
  • receiving an error code on the above.
    – Jason
    Commented May 2, 2011 at 13:59
  • The code is not exact because I do not know your specifics, but an example. It is also missing a closing }
    – Wyck
    Commented May 2, 2011 at 16:30
  • Will this work within the custom post type taxonomy? For instance my CPT is Listing with a taxonomy of Status (which includes Available, Pending, Sold)
    – Jason
    Commented May 5, 2011 at 15:41
  • It might I'm not sure, if not check out codex.wordpress.org/Function_Reference/taxonomy_exists
    – Wyck
    Commented May 5, 2011 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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