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.

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>
</p>
share|improve this question

1 Answer 1

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

 
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.