Wordpress, how to show image category
I have this code which shows default image to each category.
<?php if (is_category('name1')) { ?> <img src="<?php
bloginfo('template_directory'); ?>/images/name1.gif" alt="<?php
the_title(); ?>" width="100" height="100" />
<?php } else if (is_category('name2')) { ?> <img src="<?php bloginfo('template_directory'); ?>/images/name2.gif" alt="<?php the_title(); ?>" width="100" height="100" />
<?php } else { ?>
<img src="<?php bloginfo('template_directory'); ?>/includes/timthumb.php?src=<?php 开发者_如何学Goget_thumbnail($post->ID, 'full'); ?>&h=100&w=100&zc=1" alt="<?php the_title(); ?>" width="100" height="100"/>
<?php } ?>
Each of these categories (name1, name2, name...) belongs to the main parent category "Name". When i open each of this categories it shows the default image but when i open the main parent category it doesn't show the subcategories images. (because i get the category ID and the Parent category has a different ID)
Is there any way to do this?
Thanks
if I understand question correctly,you want to show the image in parent catogery page as well. then why dont you try
if(is_category('childname parentname')){
//show. image
}
精彩评论