Wordpress中的多重循环与分页
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress中的多重循环与分页相关的知识,希望对你有一定的参考价值。
Needed this to have the index.php or main blog page show the full content for the first two posts and then just the excerpt for the rest and still have pagination working.
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("paged=$page&posts_per_page=5"); ?> <?php $count = 1; // Sets count to 1 on first output post ?> <?php while (have_posts()) : the_post(); ?> <?php if ((!is_paged()) && ($count == 1 || $count == 2)){ // THIS STARTS FULL CONTENT IF IS FIRST POST AND NOT PAGED, THE OR OTHER COUNT ALLOWS FOR SHOWING MORE THAN ONE OF THE FULL CONTENT POSTS BEFORE GOING TO EXCERPTS ?> <?php the_content(); ?> <?php } else { // THIS ends FULL CONTENT and SHOWS FOLLOWING POSTS ELSE ?> <?php the_excerpt(); ?> <?php } $count++; // THIS IS the END of ELSE and sets count one up ?> <?php endwhile; ?> <div class="navigation"> <div class="next-posts"><?php next_posts_link('« Older Entries') ?></div> <div class="prev-posts"><?php previous_posts_link('Newer Entries »') ?></div> </div>
以上是关于Wordpress中的多重循环与分页的主要内容,如果未能解决你的问题,请参考以下文章