Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

On my index.php I'm using 'paginate links'. I want to make a pagination where you have a button for previous, than the page numbers and then a button for next, like:

< PREVIOUS  1  2  3  4  [5]  6  7  8  9  NEXT >

When the user is on the first page the button for 'previous' must be unclickable and must have another background color than normal.

The problem here is that, when I'm on the first page the whole 'previous' button disappears(same on the next page), so that makes it impossible for me to look if it has a different class so I can give it a different styling...

So what I'm wondering is:

  1. How to make the Previous and Next button appear on every page (even on the first and last page)?
  2. If they appear, how do I remove the link from the previous button when I'm on the first page (and from the next button on the last page of course)

My pagination code is:

<?php echo paginate_links( array(
    'base' => str_replace( 999, '%#%', get_pagenum_link( 999 ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages,
    'prev_text'    => __('<div class="newspage previous">vorige</div>'),
    'next_text'    => __('<div class="newspage next">volgende</div>')
) );
?>
share|improve this question
add comment

1 Answer 1

My suggestion is to build a custom function, based on the source code of paginate_links(). More specifically, you need to modify the following conditional checks so they ignore the current position and always display the link:

if ( $prev_next && $current && 1 < $current ) for the "Previous" link and

if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) for the "Next" link.

You may place it in your theme's functions.php file or in a plugin and call it as you would call paginate_links() (same parameters). Just make sure to name the new function different or you will get a PHP error "can not redeclare function".

share|improve this answer
add comment

Your Answer

 
discard

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.