I am trying to add default pagination to my WordPress loop but am unsure where to begin, most guides explain how to create custom numbered pagination. I simply need the default wp pagination. (newer posts / older posts).
Could anybody point me in the right direction?
<?php
$show_posts_number = 12;
$args=array(
'meta_key' => '_mcf_homepage',
'meta_value' => 'Yes',
'cat' => 6821, // Make the free-bingo cat id
'showposts' => $show_posts_number
);
$top_query = new WP_Query($args);
while ($top_query->have_posts()) : $top_query->the_post();
if (get_post_meta($post->ID, "_mcf_operator-name", true) != '')
$op_name = "".get_the_title()."";
?>
<div id="" class="grid_s home_list">
<div class="list_image">
<img src="https://wordpress.stackexchange.com/questions/204134/<?php bloginfo("stylesheet_directory'); ?>/images/<?php echo($op_name); ?>.jpg" />
</div>
</div>
<?php endif; endwhile; wp_reset_query();?>
<div class="clear"> </div>
1 Answer
As per comments the default pagination would go like this (insert just before wp_reset_query
)(docs):
next_posts_link( 'Older Entries', $top_query->max_num_pages );
previous_posts_link( 'Newer Entries' );
Also, as noted in comments, in your query replace showposts
with posts_per_page
.