WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 days ago

#39111 accepted enhancement

Don't output the adjacent posts rel link by default

Reported by: johnbillion Owned by: johnbillion
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch needs-testing
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 3 days ago.

Download all attachments as: .zip

Change History (11)

#1 @johnbillion
3 years ago

  • Description modified (diff)

#2 @joostdevalk
3 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
3 years ago

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

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

Replying to swissspidy:

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

Yes, and for archives.

#5 @johnbillion
3 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
3 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
4 weeks ago

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

@johnbillion
3 days ago

#10 @johnbillion
3 days 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 3 days ago by johnbillion (previous) (diff)
Note: See TracTickets for help on using tickets.