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

This is the current output for my WP_LINK_PAGES, notice the unnecessary </p> tag at the end.

My code for my custom WP_LINK_PAGES can be found here.

<div id="link_wrap"> <span class="classlinks">1</span> <a href="http://themeforward.com/demo2/?p=1948&#038;page=2"><span class="classlinks">2</span></a> <a href="http://themeforward.com/demo2/?p=1948&#038;page=3"><span class="classlinks">3</span></a> <a href="http://themeforward.com/demo2/?p=1948&#038;page=4"><span class="classlinks">4</span></a> <a href="http://themeforward.com/demo2/?p=1948&#038;page=2"><span class="classlinks">Next page</a></div>
share|improve this question
up vote 1 down vote accepted

the </p> is just a browser artefact to compensate for a missing </span>;

your code is missing . $args['link_after'] in two locations;

the corrected code:

// 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; 
    $args['before'] = '<div id="link_wrap">'; 
    $args['after'] = '</div>'; 
    $args['link_before'] = '<span class="classlinks">'; 
    $args['link_after'] = '</span>'; 
    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></div>' ; 
    return $args; 
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.