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

thanks!

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?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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"/>
share|improve this answer
    
I'll give it a shot. Thanks. –  Jason Apr 29 '11 at 11:59
    
receiving an error code on the above. –  Jason May 2 '11 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 May 2 '11 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 May 5 '11 at 15:41
    
It might I'm not sure, if not check out codex.wordpress.org/Function_Reference/taxonomy_exists –  Wyck May 5 '11 at 17:10
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.