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;

1 Answer 1


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

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.