下面的循环是自定义页面模板上的几个循环之一,但它是我尝试实现分页的唯一循环。
一旦我为这一个循环进行了分页,我将实现InfiniteScroll,我相信这比首先安装它要容易得多。。。
我已经读了好几英里的书,但我的大脑还没有找到正确的信息来让它发挥作用。
设计主题是一回事,但工程循环仍然是我难以解决的问题。
<div class="thirdLeft">
<?php
global $paged;
$curpage = $paged ? $paged : 1;
$args = array(
\'post_type\' => \'location\',
\'orderby\' => \'post_date\',
\'posts_per_page\' => 5,
\'paged\' => $paged
);
$first_query = new WP_Query(\'cat=2,-20&showposts=18&offset=2\');
while($first_query->have_posts()) : $first_query->the_post();
?>
<?php get_template_part( \'content\', \'single\' ); ?>
<?php endwhile; ?>
</div>
UPDATE
在浏览完网页后,我发现了一个很棒的图坦卡门:http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/设置上面的循环格式以工作并获得其应有的分页,更新版本如下所示:
(除了自定义类别外,与tut相比变化不大)
<?php add_filter(\'post_limits\', \'my_post_limit\'); ?>
<div class="thirdLeft">
<?php
global $myOffset;
$myOffset = 2;
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(\'offset=\'.$myOffset.\'&cat=2,-20\'.\'&showposts=18\'.\'&paged=\'.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
</div>
<div class="longLoopNav">
<div class="alignleft"><?php previous_posts_link(\'« Previous\') ?></div>
<div class="alignright"><?php next_posts_link(\'More »\') ?></div>
</div>
<?php $wp_query = null; $wp_query = $temp;?>
<?php remove_filter(\'post_limits\', \'my_post_limit\'); ?>
现在要了解如何使用Ajax无限滚动地将更多帖子加载到此循环中