Make WordPress Core

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#24940 closed defect (bug) (fixed)

wp_link_pages() adds separator before pagination links

Reported by: frank-klein's profile Frank Klein Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.6
Component: Posts, Post Types Keywords: has-patch commit
Focuses: template Cc:

Description

r23653 introduced a new 'separator' argument that can be passed to wp_link_pages(). According to the inline documentation, the separator is used between pagination links.

So if you call the function like this: wp_link_pages( array( 'separator' => ' > ' ) ); the expected output would be "Pages: 1 > 2 > 3", however the actual output is "Pages: > 1 > 2 > 3".

As I understand the documentation, the separator text should only be printed between the links and not before.

Attachments (6)

24940.patch (570 bytes) - added by Frank Klein 11 years ago.
24940.2.patch (592 bytes) - added by Frank Klein 10 years ago.
24940.3.patch (874 bytes) - added by DrewAPicture 10 years ago.
24940.twentyten.png (1.8 KB) - added by SergeyBiryukov 10 years ago.
24940.twentytwelve.png (1.1 KB) - added by SergeyBiryukov 10 years ago.
24940.4.patch (1.7 KB) - added by obenland 10 years ago.

Download all attachments as: .zip

Change History (22)

@Frank Klein
11 years ago

#1 @Frank Klein
11 years ago

  • Cc contact@… added
  • Keywords has-patch added

#3 @Frank Klein
11 years ago

Thanks for posting the link to the IRC discussion.

I still think that removing the first separator would have made more sense. If you want to add a separator before the page links, you can easily use the before argument.

But if you don't want to have a separator prepended, you need to filter the output via the wp_link_pages filter, which seems like a lot of work for the desired result.

#4 @nacin
11 years ago

  • Component changed from Themes to Posts, Post Types
  • Focuses template added
  • Keywords 2nd-opinion added

I'd agree the initial separator is weird.

#5 @obenland
10 years ago

  • Keywords needs-refresh added; 2nd-opinion removed
  • Milestone changed from Awaiting Review to 4.1

Frank, would you mind refreshing the patch with braces?

#6 @obenland
10 years ago

  • Keywords commit added; needs-refresh removed

Tested and ready to go.

This ticket was mentioned in IRC in #wordpress-dev by obenland. View the logs.


10 years ago

#8 @SergeyBiryukov
10 years ago

The issue is that themes rely on that initial separator. With the patch, there's no space between "Pages:" and the first number in both Twenty Ten and Twenty Twelve.

If two of our bundled themes rely on it, I guess there are much more in the repository that do the same.

#9 @obenland
10 years ago

  • Keywords commit removed

I obviously tested it with the wrong theme. Thanks for your feedback!

@obenland
10 years ago

#10 @obenland
10 years ago

24940.4.patch goes back to using a blank space before the first link in numbers mode, and only using the separator in next mode, when it's between the two links.

This ticket was mentioned in IRC in #wordpress-dev by obenland. View the logs.


10 years ago

#12 @SergeyBiryukov
10 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#13 @johnbillion
10 years ago

  • Keywords commit added

I'm happy with this. Just needs a final review.

This ticket was mentioned in Slack in #core by johnbillion. View the logs.


10 years ago

#15 @johnbillion
10 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 30030:

In wp_link_pages(), only output link separators between actual pagination links. Fixes #24940. Props obenland.

#16 @SergeyBiryukov
10 years ago

In 30035:

Update expected results in wp_link_pages() unit tests after [30030].

see #24940.

Note: See TracTickets for help on using tickets.