以下是我所做的,以防有人想复制它,注意到很多人在看
设置一个你选择的类别,特色图片将成为幻灯片,标题将显示出来,整个内容将永久对齐
下面是生成它的HTML/PHP
<div id="slider">
<ul id="featslider">
<?php
$portquery = new WP_Query();
$portquery->query(array(\'cat\'=> 3, \'posts_per_page\' => 4));
while ($portquery->have_posts()) : $portquery->the_post();
echo "<li class=\'featslide\' id=\'feat-".$slidecount."\'>";
echo " <a href=\'".get_permalink($post->ID)."\'>";
echo \'<span class="slide-title sosmed"> \'.the_title(\'\',\'\',false).\' </span>\';
?>
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), \'single-post-thumbnail\' ); ?>
<?php
echo "<img src=\'".$image[0]."\' />";
?>
<?php endif;
echo "</a></li>";
?>
<?php endwhile; ?>
</ul>
</div>
<div id="featslide-nav" class="slidenav">
</div>
</div>
CSS您可能需要根据您的大小对此进行修改
#slider{
height:348px;
width:800px;
overflow:scroll;
overflow-x:hidden;
position:relative;z-index:5
}
#featslider{
list-style-type:none;
margin:0;
z-index:0;
}
.featslide{margin-top:-22px;}
#featslide-nav{
z-index:100;
position:absolute;
margin-top:-24px;margin-left:700px;
}
.slide-title{
z-index:10;
color:#000;
padding:6px;
min-width:250px;
text-align:center;
background:#fff;
position:relative;top:30px;
font-size:22px;
}
.slidenav a{
text-decoration:none;
color:#fff;
background:#000;
padding:5px;
margin:2px;
cursor:pointer;
}
然后jQuery
//SLIDER CONTROLS
$("#slider").css("overflow", "hidden");
$("ul#featslider").cycle({
fx: \'fade\',
speed: 3000,
timeout: 6000,
pager:"#featslide-nav"
});
基于这篇关于在jquery循环中制作html幻灯片的博文
http://line25.com/tutorials/build-a-simple-image-slideshow-with-jquery-cycle