How to limit number of posts in index.php
I have an index.php with loop
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// render post here
<?php endwhile; ?>
<?php endif; ?>
Now I want to li开发者_运维知识库mit number of post by N on the page and create a link to next/previous N posts.
A small code snippet is very appreciated.
UPDATE
What about the URL string? I want to make functionality similar to SO where query is determined by URL for example
get next twenty questions from the recent
https://stackoverflow.com/questions?page=2&sort=active
You can achieve that in this way:
query_posts( 'posts_per_page=5' );
References: http://codex.wordpress.org/Function_Reference/query_posts http://codex.wordpress.org/Class_Reference/WP_Query
精彩评论