From b92307f58db99c8e28f0082eab3cc9cc94b43e94 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 26 Oct 2014 22:40:07 +0000 Subject: [PATCH] In `wp_link_pages()`, only output link separators between actual pagination links. Fixes #24940. Props obenland. git-svn-id: https://develop.svn.wordpress.org/trunk@30030 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post-template.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index fab9e3cc7f..b05b6eabee 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -787,7 +787,10 @@ function wp_link_pages( $args = '' ) { * @param int $i Page number for paginated posts' page links. */ $link = apply_filters( 'wp_link_pages_link', $link, $i ); - $output .= $r['separator'] . $link; + + // Use the custom links separator beginning with the second link. + $output .= ( 1 === $i ) ? ' ' : $r['separator']; + $output .= $link; } $output .= $r['after']; } elseif ( $more ) { @@ -797,16 +800,17 @@ function wp_link_pages( $args = '' ) { $link = _wp_link_page( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . ''; /** This filter is documented in wp-includes/post-template.php */ - $link = apply_filters( 'wp_link_pages_link', $link, $prev ); - $output .= $r['separator'] . $link; + $output .= apply_filters( 'wp_link_pages_link', $link, $prev ); } $next = $page + 1; if ( $next <= $numpages ) { + if ( $prev ) { + $output .= $r['separator']; + } $link = _wp_link_page( $next ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . ''; /** This filter is documented in wp-includes/post-template.php */ - $link = apply_filters( 'wp_link_pages_link', $link, $next ); - $output .= $r['separator'] . $link; + $output .= apply_filters( 'wp_link_pages_link', $link, $next ); } $output .= $r['after']; }