Make WordPress Core

Opened 4 years ago

Last modified 2 months ago

#39111 assigned enhancement

Don't output the adjacent posts rel link by default

Reported by: johnbillion Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch needs-testing dev-feedback
Focuses: performance Cc:

Description (last modified by johnbillion)

The query performed by get_adjacent_post() is an expensive one, and quickly becomes a performance bottleneck on sites with a large number of posts.

This function is called twice when viewing a single post in order to output the link rel='prev' and link rel='next' links, and is often one of the first things disabled by WordPress-specific hosts in order to increase site performance.

The usefulness of these tags is questionable. In addition, the links don't account for paginated posts (using <!--nextpage-->) and are therefore possibly incorrect in this situation.

/cc @joostdevalk for SEO review :-)

Attachments (1)

39111.diff (635 bytes) - added by johnbillion 5 months ago.

Download all attachments as: .zip

Change History (12)

#1 @johnbillion
4 years ago

  • Description modified (diff)

#2 @joostdevalk
4 years ago

+1 from me, it's actually a wrong use of rel=next and rel=prev that we correct in Yoast SEO.

#3 follow-up: @swissspidy
4 years ago

@joostdevalk How would correct usage look like? Only use it for paginated posts?

#4 in reply to: ↑ 3 @joostdevalk
4 years ago

Replying to swissspidy:

@joostdevalk How would correct usage look like? Only use it for paginated posts?

Yes, and for archives.

#5 @johnbillion
4 years ago

I'm sure I saw an existing ticket for adding rel links to archives but I can't find it now.

#6 @joostdevalk
4 years ago

That would be #18672

#7 @johnbillion
3 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to Future Release

@joostdevalk Do you want to get one of your folks to knock up a patch for this?

#8 @SergeyBiryukov
3 years ago

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

#9 @johnbillion
5 months ago

  • Milestone changed from Future Release to 5.5
  • Owner changed from SergeyBiryukov to johnbillion

5 months ago

#10 @johnbillion
5 months ago

  • Keywords has-patch needs-testing added; needs-patch removed

39111.diff removes the rel links but notably the number of database queries on the page doesn't get reduced if you use one of the default themes because they all include previous/next post links which uses the same query. If you use a theme which doesn't display previous/next post links on the page, then this provides the performance benefit as mentioned in the summary in addition to removing these tags which are unnecessary from an SEO perspective.

Last edited 5 months ago by johnbillion (previous) (diff)

#11 @johnbillion
2 months ago

  • Keywords dev-feedback added
  • Milestone changed from 5.5 to Future Release
  • Owner johnbillion deleted
  • Status changed from accepted to assigned
Note: See TracTickets for help on using tickets.