Opened 18 years ago
Closed 16 years ago
#4209 closed enhancement (fixed)
Add rel="prev" to previous_post_link() and rel="next" to next_post_link()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Template | Keywords: | has-patch |
Focuses: | Cc: |
Description ¶
Hi,
I'm wondering if you could code link-template.php to include a rel="next" in the next_post_link()-generated link, and do the same with its previous counterpart.
This could even possibly be an option in the function's arguments. See also, this page.
My main use for this would be Opera's 'Flip Forward' and 'Flip Back' mouse gestures, which can use rel="" to detect where to go.
Pull Requests
- Loading…
Change History (38)
#5
@
18 years ago
Um, actually, I am stupid. This is an attribute for <LINK>, not <A>. I think.
Either way, I applied the mod but it isn't working with my flip gestures. I'm wondering if there might have to be a separate '<link rel="next" href="whatever">' added after the <A> tag.
#6
@
18 years ago
Sure enough, this code works in Opera 9.20.8767:
$string = '<link rel="prev" href="'.get_permalink($post->ID).'" /><a href="'.get_permalink($post->ID).'">';
$string = '<link rel="next" href="'.get_permalink($post->ID).'" /><a href="'.get_permalink($post->ID).'">';
#7
@
18 years ago
According to *1 the rel="next" is valid for an <a> tag.
Adding a <link> tag after/before the <a> tag may work, but isn't allowed, because <link> tags are only allowed in the <head> section *2.
*1 http://www.w3.org/TR/html4/struct/links.html#adef-rel
*2 http://www.w3.org/TR/html4/struct/links.html#edef-LINK
#8
@
18 years ago
I think it must be a support issue in Opera itself. I'll keep my <link> usage for my personal use (since I'm the only one who sees my WordPress), and I hope other people will benefit from this patch. Thanks for all the info.
#9
@
18 years ago
We could put the <link /> tags for next/prev into the <head> automatically on is_single().
#12
@
18 years ago
We can just add it as an action to wp_head. I'll work on a patch that incorporates Nazgul's as well as the <link /> ones.
#16
@
18 years ago
I tested it in Opera, works fine. At first I needed to tweak something, but after that it was smooth sailing.
#22
@
17 years ago
I believe you can place a "rel" attribute inside the anchor (<a>) tag...
Check this: http://webdesign.about.com/od/htmltags/p/blatrel.htm
So the patch should work.
#24
@
16 years ago
- Keywords needs-patch added; has-patch removed
If this is still desired I'd expect the patch would need a fresh look.
#25
follow-up:
↓ 26
@
16 years ago
The filters "next_posts_link_attributes" and "previous_posts_link_attributes" make implementing this quite difficult to do with out breaking any plugins that may add rel attributes using them.
#26
in reply to:
↑ 25
@
16 years ago
Replying to mtekk:
The filters "next_posts_link_attributes" and "previous_posts_link_attributes" make implementing this quite difficult to do with out breaking any plugins that may add rel attributes using them.
IMHO, plugins should also check if the rel attributte has already been added in order not to add it again :-)
#27
follow-up:
↓ 28
@
16 years ago
- Component changed from Administration to Template
- Keywords has-patch added; needs-patch removed
Attached two patches.
The first one adds rel="prev/next" before xxx_posts_link_attributes is fired, thus the plugins have to check if rel is already there (IMHO they should do that anyway).
The second one lets xxx_posts_link_attributes run, then checks if rel= is already there; if not, it is added.
Personally I like the first one more, as it is simplier and plugins in theory can add their own <a> tags in xxx_posts_link_attributes, in which case rel will be added to too many places.
#28
in reply to:
↑ 27
@
16 years ago
Replying to vladimir_kolesnikov:
Attached two patches.
The first one adds rel="prev/next" before xxx_posts_link_attributes is fired, thus the plugins have to check if rel is already there (IMHO they should do that anyway).
The second one lets xxx_posts_link_attributes run, then checks if rel= is already there; if not, it is added.
Personally I like the first one more, as it is simplier and plugins in theory can add their own <a> tags in xxx_posts_link_attributes, in which case rel will be added to too many places.
Looks like the functions dealing with this have changed, and that "next_posts_link_attributes" and "previous_posts_link_attributes" are now gone.
+1 on the first patch.
When using "next_post_link"/"previous_post_link" plugin authors should be able to see what is in the rel="" attribute. The first patch should be all that is needed for it to work since no one should be adding in rel="" before the new filters are run.
In the codex we should show how to intelligently add rel="" attributes, or others using the new filters.
#29
@
16 years ago
I'm getting a malformed patch error with 4209.2.diff. 4209.1.diff applies clean and seems to do the right thing. is it rel=prev or rel=previous that we want?
I dig it.