Problem : I'm trying to display few post on my WP front page, so I used query_post to get post using some filtering argument and it's giving perfect result. Problem happens when pagination added in this query. First page is showing without any issue but res from page 2 to end it's just shown a 404 page. If I use same code on another page instead of front page or index.php it's working fine. The same code also worked on any templates also.
Spec : WP 3.9, xaamp / online server php 5.3
Solution Tried :
using wp_query, failed.
<?php
// Get all posts under category testimonials.
// The Query
global $paged;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query();
$wp_query->query('showposts=2'.'&paged='.$paged);
/*query_posts( array (
'posts_per_page' => 2,
'paged' => $paged
) );*/
// The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post(); $post_id =get_the_ID();
?>
if you use static front page then, use get_query_var('page') instead of get_query_var('paged'). hope it will work!
$paged = (get_query_var('page')) ? get_query_var('page') : 1;