Opened 14 years ago
Closed 11 years ago
#14458 closed enhancement (duplicate)
Create rel_canonical filter
Reported by: | wjm | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Canonical | Keywords: | has-patch |
Focuses: | Cc: |
Description
Wouldn't it be nice to be able to set the canonical rel value.
This comes in handy when you create a duplicate page and be able to manipulate the cannonical value.
Usage:
add_filter( 'rel_canonical', 'childtheme_rel_canonical', 10, 2 ); function childtheme_rel_canonical( $link, $id ) { return get_permalink( 55 ); }
Attachments (1)
Change History (7)
#2
@
13 years ago
- Cc ben@… added
@nacin
True, you could unhook canonical and do it yourself, but that isn't as robust as a filter.
Consider the following scenario.
If I use an SEO plugin, they will often unhook this and provide their own canonical implementation.
Now if I have a plugin installed that provides fairly complex functionality. For example, e-commerce, where you have products which would exist in multiple taxonomies under different URL paths. It is likely for such a plugin that it would want to override the canonical implementation to ensure that the most relevent URL is used as the canonical link for a product.
At this point the e-commerce plugin wouldn't necessarily know where an SEO had unhooked canonical and implemented it's own thing so you can't do anything about it. At this point it would be more helpful if canonical was a filter so that SEO plugins could filter it, then if another plugin wants to override if could apply a filter at a higher priority to override it.
Then say I create I create a plugin to add extra functionality to the e-commerce plugin and want to override their canonical functionality, I can override their filter.
I guess because the outcome of canonical should be a single value/output it should be a case of whichever plugin "shouts loudest wins" which is probably best achieve using a filter?
Not convinced this is necessary. Filters are already there for this in get_permalink(), and you could also unhook canonical and do it yourself for that page.