WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#34890 closed defect (bug) (fixed)

Canonical meta tag for paginated posts incorrect with ugly permalinks

Reported by: peterwilsoncc Owned by: wonderboymusic
Milestone: 4.4.1 Priority: normal
Severity: normal Version: 4.4
Component: Canonical Keywords: has-patch has-unit-tests fixed-major
Focuses: Cc:

Description (last modified by peterwilsoncc)

Following [34496] canonical URLs of paginated posts with ugly permalinks are incorrect.

Page http://example.com/?p=1&page=2
Canonical meta tag: <link rel="canonical" href="http://example.com/?p=1/2" />.

Going the canonical URL loads the first page.

Note: title updated to reference meta tag

Attachments (2)

34890.diff (700 bytes) - added by peterwilsoncc 5 years ago.
34890.2.diff (2.5 KB) - added by peterwilsoncc 5 years ago.

Download all attachments as: .zip

Change History (12)

@peterwilsoncc
5 years ago

#1 @peterwilsoncc
5 years ago

  • Keywords has-patch added; needs-patch removed

34890.diff corrects canonical URL for paginated posts:

  • Never adds pagination for the first page
  • Uses the page querystring if pretty permalinks are not set

Adapted from the code in _wp_link_page.

#2 @peterwilsoncc
5 years ago

  • Description modified (diff)
  • Summary changed from Canonical URLs for paginated posts incorrect with ugly permalinks to Canonical meta tag for paginated posts incorrect with ugly permalinks

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


5 years ago

#4 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 4.4.1

#5 @SergeyBiryukov
5 years ago

  • Keywords needs-unit-tests added

#6 @peterwilsoncc
5 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

34890.2.diff includes unit tests for paginated posts both with and without pretty permalinks.

Let me know if the tests needs rewriting, moving or both, it's my first attempt at unit tests.

#7 @jorbin
5 years ago

  • Owner set to wonderboymusic
  • Status changed from new to assigned

@wonderboymusic, @joostdevalk - this was introduced in [34496] which both of you worked on, can you take a look?

#8 @dd32
5 years ago

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

In 36096:

Canonical: Output correct canonical links for paged posts when not using pretty permalinks.

Props peterwilsoncc.
Fixes #34890

#9 @dd32
5 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#10 @dd32
5 years ago

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

In 36103:

Canonical: Output correct canonical links for paged posts when not using pretty permalinks.

Merges [36096] to the 4.4 branch.
Props peterwilsoncc.
Fixes #34890.

Note: See TracTickets for help on using tickets.