Javascript Wordpress post滑块
所以我想做的是有一个wordpress内容区,当点击链接时,它将显示下一篇文章。我有这个作为我的帖子查询Javascript Wordpress post滑块,javascript,php,jquery,wordpress,dynamic-data,Javascript,Php,Jquery,Wordpress,Dynamic Data,所以我想做的是有一个wordpress内容区,当点击链接时,它将显示下一篇文章。我有这个作为我的帖子查询 <?php $args = array(); $lastposts = get_posts( $args ); foreach ( $lastposts as $post ) { setup_postdata( $post ); $posts[] += $post->ID; } $current = array_search(get_the_ID(), $posts);
<?php
$args = array();
$lastposts = get_posts( $args );
foreach ( $lastposts as $post )
{
setup_postdata( $post );
$posts[] += $post->ID;
}
$current = array_search(get_the_ID(), $posts);
$prevID = $posts[$current-1];
$nextID = $posts[$current+1];
然后我把它作为分页链接
<?php if (!empty($prevID)) { ?>
<li class="previous">
<a class="panel" href="<?php echo get_permalink($prevID); ?>" title="<?php echo get_the_title($prevID); ?>">← Older</a>
</li>
<?php }
if (!empty($nextID)) { ?>
<li class="next">
<a class="panel" href="<?php echo get_permalink($nextID); ?>" title="<?php echo get_the_title($nextID); ?>">Newer →</a>
</li>
<?php } ?>
我不知道如何说出一篇文章的真谛(permalink,内容)来显示下一篇文章。我的目标是增加一些过渡,但这并不像让下一篇文章出现那样重要。有什么想法,可能吗?我一直不喜欢旋转木马和滑块,但这个特殊的滑块一直是我的首选,因为它超级简单,而且非常可定制
jcarousellite是它的名字,它很雄伟。这是网站
如果你对css有一个基本的了解,你会喜欢的,但这里有一个示例模型
<head>
<title>Test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript" src="http://www.gmarwaha.com/jquery/jcarousellite/js/jcarousellite_1.0.1.js"></script>
</head>
<body>
<button class="prev"><<</button>
<button class="next">>></button>
<div class="anyClass">
<ul>
<li><img src="someimage" alt="" width="100" height="100" ></li>
<li><img src="someimage" alt="" width="100" height="100" ></li>
<li><img src="someimage" alt="" width="100" height="100" ></li>
<li><img src="someimage" alt="" width="100" height="100" ></li>
</ul>
</div>
<script type="text/javascript">
$(function() {
$(".anyClass").jCarouselLite({
btnNext: ".next",
btnPrev: ".prev"
});
});
</script>
</body>
试验
$(函数(){
$(“.anyClass”).jCarouselLite({
btnNext:“.next”,
btnPrev:“.prev”
});
});
在这里,我将在您的服务器上至少托管jcarousellite.js文件,因为其中有一系列设置可供使用,比如一次显示一个图像,但我希望这对您有所帮助!别忘了你可以把ID添加到按钮上,让它们看起来漂亮,把所有东西都包在CSS中,使它看起来性感。 < P>用这个替换中间的Li。
<?php
$thumbnails = get_posts('numberposts=5');
foreach ($thumbnails as $thumbnail) {
if ( has_post_thumbnail($thumbnail->ID)) {
echo '<li><a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, 'medium');
echo '</a></li>';
}
}
?>
谢谢你的回答。不知道为什么有人会把我的问题降级,但不管怎样。这与我现在使用的滑块函数类似,问题是让wordpress认识到下一张幻灯片应该包含下一篇文章的内容。我将尝试创建一个遮罩,然后隐藏5个元素。然后查看向wp_content函数添加$nextID参数是否有效。如果有人知道更好的方法,请告诉我。