I need to create a wordpress-site which shows 5 posts on the front and in a different loop: 2 posts of the next page. These开发者_如何学运维 show up if you visit the second page. Do you have any ideas? I wanna show "More articles" by displaying "older" posts in a different loop.
Thanks
For the first page, limit your listing to 5 posts per page in wordpress settings.
Then you create the second page and apply a page template in witch you have made a custom query to fetch 2 posts.
$cat = get_cat_ID($category);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = 2; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => array($cat),
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'caller_get_posts' => $do_not_show_stickies
);
$temp = $wp_query; // assign orginal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if( have_posts() ) :
...
To read more, see Wordpress Codex Reference
精彩评论