Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#24940 closed defect (bug) (fixed)

wp_link_pages() adds separator before pagination links

Reported by: anonymized_8769252 Owned by: SergeyBiryukov
Priority: normal Milestone: 4.1
Component: Posts, Post Types Version: 3.6
Severity: normal Keywords: has-patch commit
Cc: Focuses: template

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 anonymized_8769252 13 years ago.
24940.2.patch​ (592 bytes ) - added by anonymized_8769252 12 years ago.
24940.3.patch​ (874 bytes ) - added by DrewAPicture 12 years ago.
24940.twentyten.png​ (1.8 KB ) - added by SergeyBiryukov 12 years ago.
24940.twentytwelve.png​ (1.1 KB ) - added by SergeyBiryukov 12 years ago.
24940.4.patch​ (1.7 KB ) - added by obenland 12 years ago.

Download all attachments as: .zip

Change History (22)

#1 @anonymized_8769252
13 years ago

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

#3 @anonymized_8769252
13 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
13 years ago

  • Component Themes → Posts, Post Types
  • Focuses template added
  • Keywords 2nd-opinion added

I'd agree the initial separator is weird.

#5 @obenland
12 years ago

  • Keywords needs-refresh added; 2nd-opinion removed
  • Milestone Awaiting Review → 4.1

Frank, would you mind refreshing the patch with braces?

#6 @obenland
12 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.


12 years ago

#8 @SergeyBiryukov
12 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
12 years ago

  • Keywords commit removed

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

#10 @obenland
12 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.


12 years ago

#12 @SergeyBiryukov
12 years ago

  • Owner set to SergeyBiryukov
  • Status new → reviewing

#13 @johnbillion
12 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.


12 years ago

#15 @johnbillion
12 years ago

  • Resolution → fixed
  • Status reviewing → closed

In 30030:

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

#16 @SergeyBiryukov
12 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.