Make WordPress Core

Opened 9 years ago

Last modified 3 months ago

#43789 new defect (bug)

the_posts_pagination() outputs the slash at the first link

Reported by: campusboy1987 Owned by:
Priority: normal Milestone: Future Release
Component: Permalinks Version: 4.9.5
Severity: normal Keywords: needs-patch needs-unit-tests
Cc: Focuses:

Description

Hello.

Permanent link settings: http://wp-test.ru/%postname% (without a slash on the end)

On the second and other pages of pagination, any category has a link to the first page with a slash on the end.

http://wp-test.ru/category/bez-rubriki/ (with a slash on the end, why?)
http://wp-test.ru/category/bez-rubriki/page/2
http://wp-test.ru/category/bez-rubriki/page/3 (current page)
.....

Attachments (1)

43789.diff​ (2.1 KB ) - added by soulseekah 8 years ago.
Prototype fix. Comments needed.

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
9 years ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone Awaiting Review → Future Release

#2 @Kubitomakita
8 years ago

I can confirm this issue. When you have pagination on category archive with at least two pages and you go to the second page, the Previous and 1 links have the trailing slash.

Bug shouldn't be very deep as the View link in wp-admin in categories shows the url without trailing slash.

Last edited 8 years ago by Kubitomakita (previous) (diff)

@soulseekah
8 years ago

Prototype fix. Comments needed.

#3 @soulseekah
8 years ago

Attached a fix that seemingly works.

What are the edge cases? Paginated loops inside shortcodes inserted in posts displayed on date archives?

Thoughts?

#4 @alaing
5 years ago

Hello, any news ? Thanks :)

#5 @sainathpoojary
3 months ago

I looked into this and couldn't reproduce the issue on the current codebase.

It looks like this trailing slash behavior on pagination links (when using a permalink structure without one, like /%postname%) was fixed in ticket #61393. paginate_links() now correctly respects the permalink settings for all the page links.

Since the underlying issue is already resolved, I think this ticket can be closed. Let me know if anyone is still seeing this or if I missed a specific edge case.

#6 @ShameemReza
3 months ago

Reproduction report for comment:5 by @sainathpoojary. I could not reproduce this on trunk either.

Environment

  • WordPress: 7.2-alpha-63166-src (trunk, local Docker environment)
  • PHP: 8.3.33
  • Theme: Twenty Twenty-One 2.9 (classic, calls the_posts_pagination()). Also checked the default block theme, which uses the query pagination block.
  • Permalink structure: /%postname% without a trailing slash, matching the original report.

Steps

  1. Set the permalink structure to /%postname% without a trailing slash.
  2. Published 12 posts in the default category with posts_per_page set to 5, which gives 3 archive pages.
  3. Visited /category/uncategorized/page/2 and inspected the pagination markup.

Results

With Twenty Twenty-One, the Previous link and the page 1 link both output http://localhost:8889/category/uncategorized with no trailing slash. The block theme produced the same URLs.

As a sanity check, I switched the structure to /%postname%/ with a trailing slash. All pagination links then carried the trailing slash, so paginate_links() follows the permalink setting in both directions.

I agree with @sainathpoojary in comment:5. This was fixed in #61393 and the ticket can be closed.

Note: See TracTickets for help on using tickets.