2012-12-01 2 views
0

내 꼬리말에 사용자 정의 포스트 유형을 타겟팅하는 스크롤식 뉴스 티커를 만들려고합니다. 여기에 자바 스크립트와 내 div 아래 있습니다. 감사.게시물 제목, 이미지 및 발췌 부분이있는 가로 스콜링 티커 만들기

$('.ticker-wrapper').cycle({ 
    fx: 'scrollHorz', 
    continuous: 1, 
    easeIn: 'linear', 
    easeOut: 'linear' 
    }); 


<div class ="ticker-wrapper"> 
<!--pulling in custom post type "Ticker"--> 
<article class="ticker"> 

<?php $recentPosts = new WP_Query("showposts=8&post_type=Ticker"); 
while($recentPosts->have_posts()):$recentPosts->the_post();?> 

<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article"> 

<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('ticker-img', array('class' => 'ticker-image'));?></a> 
<h2 class="ticker-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
<p class="ticker-excerpt"><?php the_excerpt('ticker_length'); ?></p> 
</article> <!--end ticker--> 

<?php endwhile; wp_reset_query(); ?> 
</div> <!--end ticker-wrapper--> 
+0

그럼 뭐가 궁금한가요? – AndyWarren

+0

글쎄, 내 코드가 전혀 작동하지 않습니다. 어떻게하면 스크롤을 작동시킬 수 있습니까? – amespower

+0

아래 나의 대답을 참조하십시오. – AndyWarren

답변

0

jQery 실행주기가 있는지 확인하고 jQuery 이후에 호출되는지 확인하십시오. 그런 다음 jQuery Cycle 호출에있는 기사 클래스 외부에서 사용자 정의 루프를 시작하고 종료해야합니다. 아래 코드를 시도해보십시오.

jQuery 및 jQuery Cycle에 대한 링크 뒤에 <head></head> 태그 안에 넣으십시오.

$(document).ready(function() { 
    $('.ticker-wrapper').cycle({ 
     fx: 'scrollHorz', 
     continuous: 1, 
     easeIn: 'linear', 
     easeOut: 'linear' 
    }); 
}); 

는 스크롤러가되고 싶습니다 곳을 넣습니다.

<?php $recentPosts = new WP_Query("showposts=8&post_type=Ticker"); 
while($recentPosts->have_posts()):$recentPosts->the_post();?> 

<div class="ticker-wrapper"> 

    <article <?php post_class('clearfix'); ?> role="article" class="ticker" id="post-<?php the_ID(); ?>"> 

     <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('ticker-img', array('class' => 'ticker-image'));?></a> 

     <h2 class="ticker-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
     <p class="ticker-excerpt"><?php the_excerpt('ticker_length'); ?></p> 

    </article> <!--end .ticker--> 

</div> <!--end ticker-wrapper--> 

<?php endwhile; wp_reset_query(); ?> 

나는 또한 코드를 조금 수정하고 기본적으로 위의 article 태그의 중복이었다로 article 태그 중 하나를했다. 그 기사의 클래스와 ID를 이전 기사에 추가했습니다. 이것은 작동해야하지만 PHP 또는 JS/jQuery 오류로 응답하지 않는 경우.

관련 문제