2011-10-05 98 views
0

内的电流I类有这样的循环:获取WordPress的循环

<?php while (have_posts()) : the_post(); ?> 
    <li><h2 class="titles"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2></li> 
    <li><span class="post-date">Posted <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></span><span class="post-cat">Filed under: <?php the_category(', ') ?> by <?php the_author(); ?></span></li> 
    <li><p><?php the_excerpt(); ?></p></li> 
    <div class="voting"><?php DisplayVotes(get_the_ID()); ?></div> 
<?php endwhile;?> 

我只想把这个线<div class="voting"><?php DisplayVotes(get_the_ID()); ?></div>只有当循环被引用某一类,即。 if(category =='birthdays')然后输出这一行。

我知道如何做一个if语句,但我放入什么样的条件?

回答

3

使用get_the_category功能

global $post; 
$categories = get_the_category($post->ID); 
var_dump($categories);