Can anyone please shed some light as to why the following to print out page numbers works on my local dev server but not on my live server?
Both server are running same version of PHP.
My Loop
<?php
global $paged;
$args = array(
'orderby' => 'post_date',
'posts_per_page' => 5,
'paged' => $paged
);
$query = new WP_Query($args);
if($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
//do stuff
endwhile; ?>
My Pagination
<?php echo '
<div id="pagination">
<a class="first page button" href="'.get_pagenum_link(1).'">[First]</a>';
for($i=1;$i<=$query->max_num_pages;$i++)
echo '<a class="page button" href="'.get_pagenum_link($i).'">'.$i.'</a>';
echo '<a class="last page button" href="'.get_pagenum_link($query->max_num_pages).'">[Last]</a></div>
';
endif;
wp_reset_query();
?>
The issue clearly lies within:
for($i=1;$i<=$query->max_num_pages;$i++)
The first & last print out fine – the page numbers do not.
Thanks in advance
EDIT
If i do this it works:
for($i=1;$i<=99;$i++)
So the issue is with:
$query->max_num_pages;
Any more thoughts?
try this