I have implemented a pagination links at the end of my wordpress blog page. In a one page I have 3 posts and when I click the next link of my pagination links it take me to the next page which contains the next 3 posts. I retrieve posts from only one category. But when I go to the next page the html title of that page is "Page not found" My code is like below:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('cat'=> 4, 'posts_per_page' => 3, 'paged' => $paged );
query_posts($args);
if(have_posts()) :
print ('<div class="row">');
while (have_posts()) : the_post();
$excerpt = get_the_excerpt();
//My post contents
endwhile;
if (function_exists("pagination")) {
pagination();
}
print ('<!-- end main row --></div>');
endif;
}
My pagination function is:
function pagination() {
/*
post: retun the pagination post cout and next previous buttons
*/
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) {
$pages = 1;
}
}
if(1 != $pages) {
print('<section >');
if ($paged < $pages)
echo "<a href=\"".get_pagenum_link($paged + 1)."\">NEXT</a>";
if($paged <= $pages && $paged > 1)
echo "<a href='".get_pagenum_link($paged - 1)."'>BACK</a>";
echo "<p >Page ".$paged." of ".$pages."</p>";
echo "</section>";
}
}
Please help me for this