通过无限滚动,我尝试一次加载 3 个帖子,但只填写了具有特定字段(视频)的帖子。
例如,我最近的 2 个帖子填写了字段(视频),3d 帖子没有,第 4 个帖子有。我想要帖子 1、2 和 4 加载导致 3 的原因。然后无限滚动应该加载接下来的 3 个帖子,包括视频等。
无限滚动有效,分页查询有效,但是:因为帖子 3 没有填写视频字段,无限滚动只加载帖子 1 和 2,并且不添加帖子 4 来完成我想要的 3 个帖子时间...
我的代码:
<div id="interviews">
<?php $temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('paged='.$paged.'&cat=5&showposts=3');
while ($wp_query->have_posts()) : $wp_query->the_post();
echo ('<ul id="infinite">');
if (get('video_video', 1, TRUE)) {
echo ('<li class="video">');
$home = array("h" => 290, "w" => 380, "zc" => 1, "q" =>100);
//echo get('video_video');
echo ('With: ');
echo get('participant_first_name');
echo (' ');
echo get('participant_last_name');
echo ('</li>');
}else{ $video_video=false;
echo ('');
} ?>
<?php endwhile;?>
</ul>
<?php if ($wp_query->max_num_pages > 1) : ?>
<nav id="nav-below">
<div class="nav-previous"><?php next_posts_link( __( '← More', 'intowntheme' ) ); ?></div>
</nav>
<?php endif; ?>
</div><!--End interviews-->
jQuery脚本:
jQuery('#interviews').infinitescroll({
navSelector : "#nav-below", // selector for the paged navigation (it will be hidden)
nextSelector : "#nav-below .nav-previous a", // selector for the NEXT link (to page 2)
itemSelector : "li.video", // selector for all items you'll retrieve
extraScrollPx: 50,
loading : {
msgText: "<em>Loading the next year of Grantees...</em>",
finishedMsg: "<em>You've reached the end of the Grantees.</em>"
}
});