WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to alter the pagination of WP so that it shows ONLY a Previous and/or Next button, and NOT the pages in between.

Using this snippet from the Codex:

global $wp_query;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );

And these parameters:

<?php $args = array(
'base'         => '%_%',
'format'       => '?page=%#%',
'total'        => 1,
'current'      => 0,
'show_all'     => False,
'end_size'     => 1,
'mid_size'     => 2,
'prev_next'    => True,
'prev_text'    => __('« Previous'),
'next_text'    => __('Next »'),
'type'         => 'plain',
'add_args'     => False,
'add_fragment' => ''
); ?>

But I can't get it right! It always shows: 1 2 next or previous 1 2 And I'm trying to get this: next previous

Can this be done by altering the parameters?

share|improve this question
If you only want next & previous, don't use paginate_links! What's the context? A post loop? A gallery? Is this in the front-end or admin? – TheDeadMedic Jun 28 '13 at 8:30
The page shows my posts, well, 10 of them. So, yeah, it's the post loop. But i want to give the option to see the rest of them. That's why i want the previous and/or next button. – zandwerk Jun 28 '13 at 8:42
Hmm, setting end_size => 0, and mid_size => 0 should solve it, if I understand you correctly (you use $args var as paginate_links function argument?). – Krzysiek Dróżdż Jun 28 '13 at 8:42
when i set the end_size and mid_size to 0, it still outputs 1 2 next or previous 1 2 – zandwerk Jun 28 '13 at 8:50
What's wrong with next_posts_link() & previous_posts_link()? – TheDeadMedic Jun 28 '13 at 8:53
up vote 3 down vote accepted

If you don't want to use pagination on your site, don't use paginate links function. The right way to achieve this is to use next_posts_link() and previous_posts_link() functions. These output just the link to next/prev posts like you wished.

Check these: http://codex.wordpress.org/Function_Reference/next_posts_link http://codex.wordpress.org/Function_Reference/previous_posts_link

next_posts_link( 'Older posts' );
previous_posts_link( 'Newer posts' ); 
share|improve this answer
Yes, you and The DeadMedic are right. I implemented it, and works like a charm! – zandwerk Jun 28 '13 at 10:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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