2011-10-05 5 views
0

내부의 현재 범주를 얻을 :나는이 루프가 워드 ​​프레스 루프

<?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); 
1

당신은, 각 범주에 대한 사용자 정의 테마를 만들 수 있습니다 그냥 "카테고리-ID.php"를 호출하고 원하는대로 편집 할 수 있습니다. 이 링크를 확인하십시오. http://codex.wordpress.org/Category_Templates