我已经尝试了我能想到的一切。不应该这么难。有人可以向我解释一下使用 jQuery 和 WordPress(特别是 jQuery Cycle 插件)的过程吗?
在 header.php 我有:
<?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 文件上传到我的主题目录。
在 features-work-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>
我究竟做错了什么???