我想为我的相关职位抵消4个职位。我正在使用Flowplayer的jQuery工具滚动,所以我希望人们能够滚动浏览最新的4篇帖子,然后是接下来的4篇帖子等等。
我尝试了类似的方法,但不断收到错误消息:
<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">
<!-- 1-5 -->
<div>
<!-- Related Posts-->
<?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 class="relatedPosts">
<?php
while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a>
<div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div>
// 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
<?php if( $my_query->current_post != ( $my_query->post_count - 1 ) && ( ( $my_query->current_post + 1 ) % 4 ) == 0 ):
?>
</div>
<div class="relatedPosts">
<?php
endif;
endwhile;
?>
</div>
<?php
endif; ?>
<?php
$post = $backup;
wp_reset_query(); ?>
<!-- end Related Posts-->
</div>
<!-- 6-10 -->
<div>
<!-- Related Posts-->
<!-- end Related Posts-->
</div>
</div>
</div>
<!-- "next page" action -->
<a class="next browse right"></a>
<br clear="all" />
</div>
<div class="postBoxMidInner">
<?php comments_template(); ?>
</div>
</div>
<div class="postBoxBottom"></div>
</div>
<?php endwhile; else: ?>
<p>Sorry, but you are looking for something that isn\'t here.</p>
<?php endif; ?>
我得到的错误如下:
分析错误:语法错误,在/hermes/bosweb25a/b155/ipg中出现意外的T\\u ENDWHILE。zoomingjapancom/wp内容/主题/所有子项/单个。php在线165
第165行:
<?php endwhile; else: ?>
EDIT: 这是我的原始设置,没有偏移量(只是相同的循环两次)。这工作正常,没有任何错误:
<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">
<!-- 1-5 -->
<div>
<!-- Related Posts-->
<?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),
\'showposts\'=>4, // Number of related posts that will be shown.
\'caller_get_posts\'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<div class="relatedPosts"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a>
<div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div>
<?php
}
echo \'\';
}
}
$post = $backup;
wp_reset_query();
?>
<!-- end Related Posts-->
</div>
<!-- 10-15 -->
<div>
<!-- Related Posts-->
<?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),
\'showposts\'=>4, // Number of related posts that will be shown.
\'caller_get_posts\'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<div class="relatedPosts"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a>
<div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div>
<?php
}
echo \'\';
}
}
$post = $backup;
wp_reset_query();
?>
<!-- end Related Posts-->
</div>
这是整首单曲。php:
http://pastebin.com/x2mbQUFM我似乎无法发现错误,希望有人能帮助我。提前多谢!