当我使用jQuery工具时;“可滚动”;“我的相关帖子”部分(参见示例here), 我想知道如何实现偏移,以便在第一个循环中显示前4个帖子,然后显示接下来的4个相关帖子等。我现在正在考虑创建3个这样的循环,显示最新的12个相关帖子。
我当前的设置如下:(已更新!)
<h2>Related Posts</h2>
<!-- "previous page" action -->
<a class="prev browse left"></a>
<!-- root element for scrollable -->
<div class="scrollable" id=chained>
<!-- root element for the items -->
<div class="items">
<?php
$backup = $post;
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args = array(
\'tag__in\' => $tag_ids,
\'post__not_in\' => array($post->ID),
\'posts_per_page\'=> 12
);
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ):
?>
<div>
<?php
while ( $my_query->have_posts() ) : $my_query->the_post();
the_title();
// if this is not the last post
// and remainder of current post plus one then divided by four is zero
// close the container and open a new one
if( $my_query->current_post != ( $my_query->post_count - 1 ) && ( ( $my_query->current_post + 1 ) % 4 ) == 0 ):
?>
</div>
<div>
<?php
endif;
endwhile;
?>
</div>
</div></div>
<!-- "next page" action -->
<a class="next browse right"></a>
<br clear="all" />
然而,我只是不知道如何在现有代码中实现它。不确定这是否可行,或者我是否必须首先使用不同的方法来创建循环以使其工作?
提前非常感谢!:)
EDIT: Last updated on October 16th. I still haven\'t figured this out, please help!