开发者

How to limit number of posts in index.php

开发者 https://www.devze.com 2023-03-11 04:15 出处:网络
I have an index.php with loop <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>

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

0

精彩评论

暂无评论...
验证码 换一张
取 消