2012-09-10 3 views
0

나는 온라인 잡지를 만들고 있습니다. 지금 나는 게시하고있는 게시물을 표시하려고 노력 중입니다. 나는 그것을 할 수 있었지만, 내가 원하는 것은 포스트가 "Streetstyle"으로 분류된다면, "사진"으로 분류되면 루프가 완전히 달라진다는 것입니다. 하나의 카테고리로이 작업을 수행하는 방법에 대해 맹신적으로 생각해 보았습니다. 다른 카테고리와 동일한 작업을 수행하고 다른 방식으로 스타일을 지정할 수 있습니까? 내가 <?php if (is_category('Streetstyle') || in_category('Streetstyle')) { ?>과 같은 코드를 사용해 보았지만, 테마가 도청 당하고 게시물이 두 번 나타납니다. 이 작업을 수행하는 더 좋은 방법을 알고 있습니까?Wordpress : 다른 루프 사용

이 내 코드입니다 : 당신은 내가 스위치를 사용하는 것이 좋습니다 범주가 많은 경우

<?php query_posts('posts_per_page=9' . '&orderby=date'); 
     while (have_posts()) : the_post(); ?>   
      <?php if (is_category('Streetstyle') || in_category('Streetstyle')) { ?> 
       <div <?php post_class('pin streetstyle'); ?>> 
       <a href="<?php the_permalink(); ?>"> 
       <div class="heading"> 
       <h1>Fashion</h1> 
       </div> 
       <?php if (has_post_thumbnail()) { 
        the_post_thumbnail(); 
       } 
       ?> 
       <div class="heading"> 
       <h1><?php the_title(); ?></h1> 
       </div> 
       </a> 
       </div> 
      <?php } else { ?> 
       <div <?php post_class('pin'); ?>> 
       <h1> 
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
       </h1> 
       <?php if (has_post_thumbnail()) { 
        the_post_thumbnail(); 
       } 
       the_content('Les mer <br><br>'); ?> 
       </div> 
      <?php } ?>   
     <?php endwhile; 
     // Reset Query 
     wp_reset_query(); ?> 
+0

후있어 무엇보다 아마, 당신이 사용하는 CSS를 달성하려고 했습니까? 그리고'query_posts' 대신'pre_get_posts' hook을 사용해야합니다 – soju

답변

0

나는 조금이 몸매는 여전했지만, 이것은 당신이 디스플레이 문제 때문에

<?php query_posts('posts_per_page=9' . '&orderby=date'); 
    while(have_posts()) : the_post(); ?>   
    <?php if(is_category('Streetstyle') || in_category('Streetstyle')) : ?> 
     <div <?php post_class('pin streetstyle'); ?>> 
      <a href="<?php the_permalink(); ?>"> 
       <div class="heading"> 
      <h1><?php the_title(); ?></h1> 
       </div> 
      </a> 
     </div> 
     <?php if(has_post_thumbnail()) the_post_thumbnail(); ?> 
    <?php else : ?> 
     <div <?php post_class('pin'); ?>> 
      <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> 
      <?php 
       if(has_post_thumbnail()) the_post_thumbnail(); 
       the_content('Les mer <br><br>'); 
      ?> 
     </div> 
    <?php endif; ?>   
<?php endwhile; wp_reset_query(); ?>