views:

2805

answers:

2

I have tried everything that I can think of. It shouldn't be this hard. Can some one please explain to me the process of using jQuery with WordPress (specifically jQuery Cycle Plugin)?

in header.php I have:

<?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();
?>

I have uploaded those two js files to my theme's directory.

In featured-work-slideshow.js I have:

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

And in my template, I have:

<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>

What am I doing wrong???

+1  A: 

BAAAAH!!! I've figured it out. I accidentally forgot to specify the right path:

<?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();
?>

should have been

<?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();
?>

otherwise, it works just fine

Andrew
A: 

man, what jQuery version are you using?

Ganhe dinheiro Blogando