Make WordPress Core

Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#39111 closed enhancement (fixed)

Don't output the adjacent posts rel link by default

Reported by: johnbillion's profile johnbillion Owned by: johnbillion's profile johnbillion
Milestone: 5.6 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 4 years ago.

Download all attachments as: .zip

Change History (17)

#1 @johnbillion
7 years ago

  • Description modified (diff)

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

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

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

Replying to swissspidy:

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

Yes, and for archives.

#5 @johnbillion
7 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
7 years ago

That would be #18672

#7 @johnbillion
7 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
7 years ago

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

#9 @johnbillion
4 years ago

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

@johnbillion
4 years ago

#10 @johnbillion
4 years 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 4 years ago by johnbillion (previous) (diff)

#11 @johnbillion
4 years ago

  • Keywords dev-feedback added
  • Milestone changed from 5.5 to Future Release
  • Owner johnbillion deleted
  • Status changed from accepted to assigned

#12 @johnbillion
4 years ago

  • Milestone changed from Future Release to 5.6
  • Owner set to johnbillion
  • Status changed from assigned to accepted

#13 @johnbillion
4 years ago

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

In 48966:

Posts, Post Types: Don't output the adjacent posts rel link by default.

This has a considerable performance impact on sites which don't otherwise show previous and next post links, and has no SEO benefit.

Props joostdevalk, swissspidy, johnbillion

Fixes #39111

#14 @jnylen0
4 years ago

Should the adjacent_posts_rel_link_wp_head function be marked as deprecated also? I don't see that it's used anywhere else.

Also just a note for others following this ticket, enabling memcached or another object caching solution will help this performance issue significantly, since the get_adjacent_post function uses wp_cache_set and wp_cache_get appropriately.

#15 @johnbillion
4 years ago

I don't think there's a need to deprecate the function. It still functions as expected, and plugins may wish to use it, it's just no longer used in core.

#16 @SergeyBiryukov
4 years ago

In 48995:

Docs: Add a @since note about adjacent_posts_rel_link_wp_head() no longer being used in core.

Follow-up to [48966].

Props jnylen0.
See #39111.

Note: See TracTickets for help on using tickets.