I followed the very simple tutorial that’s on this page: http://wp.tutsplus.com/tutorials/wordpress-pagination-a-primer/ (Scroll down to “A Better Solution”) – He makes it seem so simple, and it works in that the pagination links are there and the URL changes in the address bar, but it doesn’t actually update when clicking on 2 or 3..
Site – chrisayreswebdev.com/besh
I know I’m missing something, just not sure what. Any ideas? Thanks!
EDIT:
functions.php:
function paginate() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'current' => $current_page,
'total' => $total_pages,
));
}
}
index.php:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post">
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a></h1>
<h4>Posted on <?php the_time('F jS, Y') ?></h4>
<div class="horzline"></div>
<p><?php the_content(__('(more...)')); ?></p>
</div>
<?php endwhile; else: ?>
<p><?php _e("Sorry, we couldn't find the post you are looking for."); ?></p>
<?php endif; ?>
<?php paginate(); ?>
I suspect your problem is here:
You’re passing
1
toget_pagenum_link()
, rather than the actual page number. Try passing your previously determined$current_page
instead:Note, I use this as
base
:Edit
The best I can do is to give you my full, working code: