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 make a post pagination like this:

button left image | 1 2 3 4 5 |button right image

but I can't get it work. I've tried:

<?php wp_link_pages('before=<p>&after=</p>&next_or_number=number&pagelink= %'); ?>

But how to add images to the left an right as buttons? thx! AD

share|improve this question

migrated from stackoverflow.com Jun 22 '12 at 14:43

This question came from our site for professional and enthusiast programmers.

About the wp_link_pages functions you can read in the WordPress Codex http://codex.wordpress.org/Function_Reference/wp_link_pages.

Here you go:

        'before' => '<div class="pagenav">',
        'after' => '</div>', 
        'next_or_number' => 'next', 
        'nextpagelink' => __('<img src="IMAGE SRC HERE" />'), 
        'previouspagelink' => __('<img src="IMAGE SRC HERE" />')

Good luck! :)

share|improve this answer
Dear Grávuj - thank you very much. But I can't get the numbers inbetween the buttons so far. btn - 12345 - btn – ad2003 Jun 21 '12 at 14:57
so it works now? – Grávuj Miklós Henrich Jun 21 '12 at 17:15
up vote 0 down vote accepted

yes, it works now! Thanks

I use this code to turn ['next_or_number'] == 'next_and_number') so I can mix it with numbers, arrows or graphics :

// Custom Next/Previous Page
add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add');
 * Add prev and next links to a numbered link list
function wp_link_pages_args_prevnext_add($args)
    global $page, $numpages, $more, $pagenow;

    if (!$args['next_or_number'] == 'next_and_number') 
        return $args; # exit early

    $args['next_or_number'] = 'number'; # keep numbering for the main part
    if (!$more)
        return $args; # exit early

    if($page-1) # there is a previous page
        $args['before'] .= _wp_link_page($page-1)
            . $args['link_before']. $args['previouspagelink'] . $args['link_after'] . '</a>'

    if ($page<$numpages) # there is a next page
        $args['after'] = _wp_link_page($page+1)
            . $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'
            . $args['after']

    return $args;

to get the pagination nav:

        'before' => '<div class="pagenav">' . __(''),
       'after' => '</div>', 
        'next_or_number' => 'next_and_number', # activate parameter overloading
        'nextpagelink' => __('<img src="'.get_bloginfo('template_url').'/images/nxt_btn.png" />'),
        'previouspagelink' => __('<img src="'.get_bloginfo('template_url').'/images/prv_btn.png" />'),
    'pagelink' => '%',
    'echo' => 1 )

Thank you!


share|improve this answer

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.