2017-04-13 4 views
0

나는 회전 목마에 최신 WordPress 게시물을 가져 오려고하지만 오류도받지 못했습니다! 여기 WordPress 최신 게시물 회전 목마

은 여기에 ... 내 JS

<div class = "jumbotron"> 
    <div id  = "carousel-example-generic" 
     class  = "carousel slide" 
     data-ride = "carousel"> 
     <?php 
      $my_query = new WP_Query(); 
      $my_query -> query('showposts = 12'); 
      $x == 0; 
      $do_not_duplicate = $post -> ID; 

      echo ' <ol class = "carousel-indicators">\n'; 

      while ($my_query -> have_posts()) : $my_query->the_post(); 

       echo '  <li data-target = \"#carousel-example-generic\" data-slide-to = "' . 
          $x . 
         '"'; 

       $x++; 

       if($x == 0) 
       { 
        echo ' class = \"active\"'; 
       } 

       echo '>\n' . 
        '  </li>\n'; 
      endwhile; 

      echo ' </ol>\n'; 
     ?> 

     <!-- Carousel items --> 
     <div class="carousel-inner"> 
      <?php 
       $x == 0; 

       while ($my_query -> have_posts()) : $my_query -> the_post(); 
      ?> 

      <div class = "<?php if ($x == 0){ echo 'active item';} else { echo 'item';}?>"> 
       <a href = "<?php the_permalink() ?>" 
        title = "<?php the_title();?>"> 
        <?php echo get_the_post_thumbnail($id, 
                 'sliderimg');?> 
       </a> 

       <div class = "carousel-caption"> 
        <a href = "<?php the_permalink()?>" 
         rel = "bookmark" 
         title = "Permanent Link to <?php the_title_attribute();?>"> 
         <?php the_title(); ?> 
        </a> 
       </div> 
      </div> 

      <?php 
       endwhile; 
      ?> 
     </div> 

     <!-- Carousel nav --> 
     <a class  = "left carousel-control" 
      data-slide = "prev" 
      href  = "#carousel-example-generic"> 
      <span class = "glyphicon glyphicon-chevron-left"> 
      </span> 
     </a> 

     <a class = "right carousel-control" 
      data-slide = "next" 
      href = "#carousel-example-generic"> 
      <span class = "glyphicon glyphicon-chevron-right"> 
      </span> 
     </a> 

     <?php 
      wp_reset_query(); 
     ?> 
    </div> 
</div> 

내가 사용하는 코드입니다 :

jQuery(document).ready(function($) 
          { 
           $('.carousel').carousel({ 
                  interval : 1000 
                 } 
                 ) 
          } 
         ); 

당신이 어떤 생각을 가지고 있다면 제발 도와주세요.

미안하지만 여기에이 사이트에 그냥 더미 텍스트가 내 질문을 게시하자! 제 질문은 간단하고 분명했습니다. 제 질문을 게시 할 수있을 때까지 더 말해야 할 것이 무엇인지 모르겠습니다! 루프이 코드를 대체하면서

+0

일반 js 파일을 호출 했습니까?

+0

@RajKumarBhardwaj 예 그렇다면 HTML 캐 러셀 만 사용하면 모든 것이 작동 했으므로 PHP 코드에 문제가 있다고 생각해보십시오. –

+0

내 끝에서 시험해 보겠습니다. 위 코드에서 수정 사항을 원하십니까? –

답변

0

첫째, 다운로드의 슬라이더 https://tympanus.net/codrops/2011/08/16/circular-content-carousel/

<div id="primary" class="content-area"> 
     <main id="main" class="site-main" role="main"> 
<div class="container"> 
      <div id="ca-container" class="ca-container"> 
       <div class="ca-wrapper"> 
      <?php 
      if (have_posts()) : 

       /* Start the Loop */ 
       while (have_posts()) : the_post(); 
?> 

       <div class="ca-item ca-item-1"> 
         <div class="ca-item-main"> 
          <div class="ca-icon"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> 
     <?php the_post_thumbnail(); ?> 
    </a></div> 
          <h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> 
          <h4> 
           <span class="ca-quote">&ldquo;</span> 
           <span><?php the_excerpt(); ?></span> 
          </h4> 
           <a href="#" class="ca-more">more...</a> 
         </div> 
         <div class="ca-content-wrapper"> 
          <div class="ca-content"> 
           <h6><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h6> 
           <a href="#" class="ca-close">close</a> 
           <div class="ca-content-text"> 
            <p><?php the_content(); ?></p> 
           </div> 
           <ul> 
            <li><?php the_time('F jS, Y'); ?></li> 
            <li></li> 
            <li><?php the_author_posts_link(); ?></li> 
           </ul> 
          </div> 
         </div> 
        </div> 
        <?php 

       endwhile; 



      else : 

       get_template_part('template-parts/post/content', 'none'); 

      endif; 
      ?> 
      </div> 
      </div> 
      </div> 

<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/demo.css" /> 
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/style2.css" /> 
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.0.min.js"></script> 
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.easing.1.3.js"></script> 
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.contentcarousel.js"></script> 
<script type="text/javascript"> 
$('#ca-container').contentcarousel(); 
</script> 

     </main><!-- #main --> 
    </div><!-- #primary --> 

는이 같은

https://tympanus.net/Development/CircularContentCarousel/

처럼 작동합니다 게시 테마 디렉토리에있는 당신의 JS 및 CSS 파일을 추가
+0

로컬로 추가 스크린 샷을 http://prntscr.com/ewpeko –

+0

안녕하세요, 덕분에,하지만이 문제는, 먼저 : 나는 색인 페이지에서 회전 목마를 보여주고 싶습니다 그리고 그것은 일반 설정의 번호를 가져옵니다 나는 내가 마지막으로 5 개의 게시물을 보여주고 싶지 않은 것을 읽었습니다. wp_query로 끝낼 수 있다는 것을 알고 있지만 정확히 어떻게 알지 못합니다! 두 번째 : 나는 각 항목에 단 하나의 슬라이드 만 보여주고 싶지 않다. 3. 너는 나를 그렇게 이끌 수 있을까? 감사. –

+0

홈 페이지를 표시하려면 블로그 게시물을 집으로 만들거나 위의 우편 번호가있는 홈 페이지에 템플릿을 지정하십시오. 2 번째로 admin에서 홈 페이지 1에 게시물을 설정하고 슬라이더 javascript로 쇼 항목 1을 만듭니다. –