I'm trying to paginate some custom posts types, and the previous link works, but not the next link. I tried several ways but I'm not able to find the correct one... if anyone could help :)
This is my code :
function livredor_function($atts,$content=''){
extract(shortcode_atts(array(
id => ''
), $atts));
ob_start();
function create_guestbook() {
$i = 1;
$max_entries_per_page = 0;
$current_page = (get_query_var('paged')) ? get_query_var('paged') : 0;
$gbquery = new WP_query("post_type=inliguestbook&showposts=10&paged=" . $current_page);
while($gbquery->have_posts()) { $gbquery->the_post();
?>
<div class="guestbook">
<h3><?php the_title(); ?> <span><?php the_time('j F Y') ?></span></h3>
<?php the_content(); ?>
</div>
<?php
$i++;
}
?>
<div class="pagenav">
<div class="pagnext"><?php next_posts_link('—›', $max_entries_per_page) ?></div>
<div class="pagprev"><?php previous_posts_link('‹—', $max_entries_per_page) ?></div>
</div>
<?php
}
$gbquery = null; $gbquery = $temp;
wp_reset_query();
return create_guestbook() . ob_get_clean();
}
add_shortcode('livredor','livredor_function');
previous_posts_link()
&next_posts_link()
- plural - and secondlyprevious_post_link()
&next_post_link()
- singular. You are mixing them. Intentionally? Or is this the source of your problem?$max_entries_per_page
do$gbquery->max_num_pages
for younext_posts_link()
call. For theprevious_posts_link()
call it is generally not needed.