2

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="<?php bloginfo('stylesheet_directory'); ?>/images/<?php echo($op_name); ?>.jpg" />
            </div>
    </div>



<?php endif;  endwhile; wp_reset_query();?>

<div class="clear">&nbsp;</div>
1

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.