[wp-trac] [WordPress Trac] #36168: Introduce get_canonical function

WordPress Trac noreply at wordpress.org
Tue Mar 8 09:17:48 UTC 2016

#36168: Introduce get_canonical function
 Reporter:  joostdevalk  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Canonical    |    Version:
 Severity:  normal       |   Keywords:  has-patch dev-feedback
  Focuses:               |
 == Short version ==

 We need a function that allows consistent retrieving and filtering of the
 canonical URL. I'm proposing creating a `get_canonical_url` function to do
 just that.

 == Explanation ==

 With the advent of more and more different ways to deliver content, we
 need to make sure the canonical URL on all these different manifestations
 of content is correct. Right now, all the plugins out there, for instance
 template-actions.php#L14 the AMP plugin here], the
 wp/blob/e785259b303eb28ca418682e1feea5e87338655e/template.php#L5 the
 Instant Articles plugin here] and core's own post oEmbed functionality,
 all in some way use `get_permalink` to get the canonical. The
 [https://support.google.com/webmasters/answer/139066?hl=en|whole point of
 a canonical URL] is that it can point to the canonical version and that
 this does ''not necessarily'' have to be the representation in the WP
 database. Thus you need to be able to filter it.

 I'm attaching a patch that introduces `get_canonical_url` and uses this in
 core's `rel_canonical` function, which is used on both the normal output
 of posts and pages as well as on oEmbed iframes.

Ticket URL: <https://core.trac.wordpress.org/ticket/36168>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list