0

I'm using a code called custom_link_pages to generate my multiple page post links, but I'm getting a space between my page numbers and previous link, but my next link is missing the same space. These need to be spaced equally so I would like to either add the necessary space or remove all spaces.

For reference to what I'm talking about, view line 281 at: http://themeforward.com/demo2/?p=1813&page=2

I am assuming this could be from the custom code in my functions:

    // 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;
}

How I grab that code:

<?php
custom_link_pages(array(
    'before' => '<div class="pagelinks">' . __(''),
    'after' => '</div>',
    'next_or_number' => 'next_and_number', # activate parameter overloading
    'nextpagelink' => __('Next'),
    'previouspagelink' => __('Previous'),
    'pagelink' => '%',
    'echo' => 1 )
);
?>
  • What is this __('') thingy? – fuxia Jan 25 '12 at 9:03
  • @toscho it's for localization. – Brooke. Jan 25 '12 at 9:05
  • 1
    @BandonRandon A localized space? Really? ;) – fuxia Jan 25 '12 at 9:06
  • @toscho, Apparently, I don't see no harm in it. That would allow for removal or addition of space using a translation file. – Brooke. Jan 25 '12 at 9:09
  • Without context it is problably one of the worst strings to translate ever. Plus, there are not that much different spaces in different languages. – fuxia Jan 25 '12 at 9:14
3

This may sound stupid but why not just add the space in your function? There are several places to do it:

'nextpagelink' => __(' Next')

$args['link_before'] . ' ' . $args['nextpagelink'] . $args['link_after'] . '</a>'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.