我根据Slides (slideshow plugin for jQuery)
用法示例:
functions.php
function featured_posts( $category=\'featured\', $limit=\'-1\' ) {
$category = get_category_by_slug( $category );
$posts = get_posts( array( \'category\' => $category->cat_ID , \'orderby\' => \'rand\' , \'DESC\' , \'numberposts\' => $limit ));
foreach ($posts as $post) {
$post_title = htmlspecialchars(stripslashes($post->post_title));
echo \'
<div class="slide">
<div class="slide-title">\'.$post->post_title.\'</div>
<div class="slide-content">\'.$post->post_content.\'</div>
</div>\';
}
}
footer.php
<script type="text/javascript">
jQuery().ready(function() {
jQuery(\'#slides\').slides({
play: 4000,
hoverPause: false,
generatePagination: true,
});
});
</script>
您还必须注册幻灯片。函数中的js。php,例如:
wp_enqueue_script( \'slides.jquery.js\' , get_option( \'siteurl\' ) . \'/wp-content/themes/YOUR THEME/js/slides.jquery.js\' , array(\'jquery\') , \'1.0\' );