Just replace a> <a
with a><a
:
echo str_replace( 'a> <a', 'a><a', wp_link_pages( array ( 'echo' => FALSE ) ) );
If you want to remove the spaces around unlinked numbers too, I suggest a separate function in your theme’s functions.php
to keep the code readable:
function trimmed_link_pages( $args = array () )
{
$args['echo'] = FALSE;
$links = wp_link_pages( $args );
$links = str_replace(
array ( 'a> ', ' <a', ':<a' ),
array ( 'a>', '<a', ': <a' ),
$links
);
print $links;
}
Use it like wp_link_pages()
:
if ( have_posts() )
{
while ( have_posts() )
{
the_post();
print '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
the_content();
trimmed_link_pages();
}
}