2013-02-15 2 views
0

나는 슬라이더 (Filament Group Responsive Carousel)에서 가장 최근의 상위 4 개의 게시물을 표시하는 Wordpress 용 코드를 작성했습니다. 게시물을 표시하고 슬라이딩하는 등의 작업을 수행하지만 4 개의 슬라이더가 있으며 각 슬라이더에 4 개의 게시물이 있습니다. 코드의 일부를 WP_Query()과 틀리게 배치해야합니다. 여기 내 코드입니다 :Wordpress, Slider의 최근 게시물

그래서
<div class="carousel slider carousel-slide" data-transition="slide" data-autoplay="" data-interval="5000" data-paginate="true"> 
    <?php 
     $topNews = new WP_Query(); 
     $topNews->query('showposts=4'); 
     while ($topNews->have_posts()) : $topNews->the_post(); ?> 
      <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
       <header class="entry-header"> 
        <?php if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. 
         the_post_thumbnail('full'); 
       } ?> 
        <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr(sprintf(__('Permalink to %s', 'android_and_tea'), the_title_attribute('echo=0'))); ?>" rel="bookmark"><?php the_title(); ?></a></h1> 
       </header> 
      </div> 
     <?php endwhile; ?> 
</div> 

내 질문에, 나는이 위치를 변경해야합니까 어떤 코드/변경/대신 4 개 슬라이더, 그것은는 4 가장 최근의 게시물과 함께 하나의 슬라이더를 표시 얻기 위해 추가/제거 가장 최근 게시물 4 ​​개?

+0

은 전체 회전 목마 슬라이드 DIV 페이지에 4 번 반복인가? –

+0

@PhilippeBoissonneault 예. 그러나 내가 원하는 4 개의 게시물은 거기에 있으며 잘 작동합니다 (슬라이딩 및 모든 것). –

+0

'while (have_posts) : the_post();'가 있으면이 코드 세트를 살펴보십시오 ... –

답변

0

내 생각 엔 당신이 루프 예 :로 코드를 호출 할 것입니다

if(have_posts()) while(have_posts()): the_post(); 

//HERE IS YOUR CODE 

endwhile; 
당신은이 루프 전이나 후에 코드를 이동하거나 루프 예 :

//if(have_posts()) while(have_posts()): the_post(); 

//HERE IS YOUR CODE 

//endwhile; 
을 제거해야합니다

또는

//HERE IS YOUR CODE 
if(have_posts()) while(have_posts()): the_post(); 

endwhile; 
+0

안녕하세요, 죄송 합니다만, 이들 중 어느 것도 작동하지 않습니다. 공백은 슬라이더가 있어야하고 div에 아무것도로드되어 있지 않은 곳입니다. 노력해 주셔서 감사합니다 :) –

+0

PHP 파일에서 전체 코드를 보여줄 수 있습니까? –

관련 문제