2009-05-29 4 views
1

나는 내가 생각할 수있는 모든 것을 시도했다. 이 일이 어렵지 않아야합니다. 어떤 사람이 WordPress (특히 jQuery Cycle Plugin)에서 jQuery를 사용하는 과정을 설명해 주시겠습니까? header.php에서WordPress에서 jQuery Cycle Plugin을 사용하는 방법은 무엇입니까?

나는이 :

<?php 
    wp_enqueue_script('jquery.cycle.all.min', '/wp-content/themes/andrewhavens/jquery.cycle.all.min.js', array('jquery')); 
    wp_enqueue_script('featured-work-slideshow', '/wp-content/themes/andrewhavens/featured-work-slideshow.js'); 
    wp_head(); 
?> 

내 테마의 디렉토리에 두 JS 파일을 업로드했습니다. 기능 - 작업 slideshow.js에서

내가 가진 :

jQuery(document).ready(function($) { 
    $('#featured-works').cycle('fade'); 
}); 

그리고 내 템플릿에

, 나는이 : 내가 잘못 뭐하는 거지

<div id="featured-works"> 
    <?php query_posts('category_name=featured-work&showposts=5'); ?> 
    <?php while (have_posts()) : the_post(); ?> 
     <div class="featured-work"> 
      <div class="featured-work-image-container" style="float:left; width:600px;"> 
       <?php $image = get_post_meta($post->ID, 'homepage-image', true); ?> 
       <img src="<?php echo $image; ?>" width="500" height="300" style="margin-left:30px;"> 
      </div> 
      <p style="float:left; width:300px;"> 
       <?php the_title(); ?><br /> 
       <a href="<?php the_permalink() ?>">Read More!</a> 
      </p> 
     </div> 
    <?php endwhile;?> 
</div> 

???

답변

2

를 여러분의 인생을 더 쉽게 만들기 위해 get_bloginfo ("stylesheet_directory")를 던져 잘 작동 : 실수로 올바른 경로를 지정하는 것을 잊었다
<?php wp_enqueue_script('jquery.cycle.all', get_bloginfo("stylesheet_directory") . '/js/jquery.cycle.all.js', array('jquery')); ?> 
+0

니스! 그 기능이 존재하는지 몰랐다. 하지만 자바 스크립트 파일 일 때 왜 "스타일 시트 디렉토리"를 지정하고 있습니까? "javascripts 디렉토리"기능이 있습니까? – Andrew

+0

@Andrew 지정된'js' 디렉토리가 없지만 [get_template_directory_uri()] (http://codex.wordpress.org/Function_Reference/get_template_directory_uri) 또는 [get_stylesheet_directory_uri] (http : //codex.wordpress)를 사용하는 것이 좋습니다. .org/Function_Reference/get_stylesheet_directory_uri). –

4

알아 냈습니다.

<?php 
    wp_enqueue_script('jquery.cycle.all.min', '/wp-content/themes/andrewhavens/jquery.cycle.all.min.js', array('jquery')); 
    wp_enqueue_script('featured-work-slideshow', '/wp-content/themes/andrewhavens/featured-work-slideshow.js'); 
    wp_head(); 
?> 

것은 그렇지

<?php 
    wp_enqueue_script('jquery.cycle.all.min', '/wp-content/themes/andrewhavens/js/jquery.cycle.all.min.js', array('jquery')); 
    wp_enqueue_script('featured-work-slideshow', '/wp-content/themes/andrewhavens/js/featured-work-slideshow.js'); 
    wp_head(); 
?> 

있었어야했는데, 그것은