2011-06-22 72 views
0

我有这个代码显示每个类别的默认图像。WordPress的,如何显示图像类别

<?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 get_thumbnail($post->ID, 'full'); ?>&amp;h=100&amp;w=100&amp;zc=1" alt="<?php the_title(); ?>" width="100" height="100"/> 
    <?php } ?> 

这些类别(name1,name2,name ...)中的每一个都属于主父类别“Name”。当我打开每个类别它显示默认图像,但是当我打开主要父类别它不显示子类别图像。 (因为我得到类别ID和父类别有不同的ID)

有没有办法做到这一点?

感谢

回答

0

,如果我理解正确的问题,你想显示在父catogery页的映像。那你为什么不试试

if(is_category('childname parentname')){ 
    //show. image 
}