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

Below is a functions.php code for wp_link_pages which allows pagination and previous/next links to be displayed. It also wraps each pagination link in a span class called "classlinks".

I need to change the default "Pages:" before the pagination while maintaining the rest of the code. My attempts removed the ability to show both next/previous links and pagination. Any help?

// WP_LINK_PAGES: Add prev and next links to a numbered link list
add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add');

    function wp_link_pages_args_prevnext_add($args)
    global $page, $numpages, $more, $pagenow;

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

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

    $args['link_before'] = '<span class="classlinks">';
    $args['link_after'] = '</span>';

    return $args;
share|improve this question
up vote 1 down vote accepted

Add, right after the declaration of the global vars, e.g.: $args['before'] = '<p>Hello world: ';

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.