/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // If we're on the index page, we only want the two first posts. if ( is_home() && !is_paged() ) query_posts('posts_per_page=2'); // If we're within the index archives, we want ten posts per page as usual. else { // If we are past the second page, offset by an appropriate amount for the page. // I'm by no means a math guru; I don't know why this works. Trial & error rocks! if ( get_query_var('paged') != 2 ) $offsetting = 2 + ( ( get_query_var('paged') - 2 ) * get_query_var('posts_per_page') ); // If we're on the second page, offset by two. else $offsetting = 2; // Plug it into our query. query_posts($query_string . "&offset=$offsetting"); } ?>
URL: http://pastebin.com/f318db5f3
Comments
