Opened 11 years ago
Closed 10 years ago
#4981 closed enhancement (fixed)
Regenarate url's in Rel Next/Prev According buddypress pages
Reported by: | megainfo | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | minor | Version: | 1.7 |
Component: | Core | Keywords: | has-patch commit |
Cc: |
Description
In all Byuddypress pages, the rel='next' and rel='prev' are generated by wordpress.
it would be interesting to regenarate them according the current buddypress page.
Attachments (1)
Change History (14)
#2
@
11 years ago
My opinion is we should remove these prev / next links when on a BuddyPress page.
For most BP activity types (groups, users, etc), the concept of "previous" and "next" items doesn't really make sense anyway. So IMO it definitely makes sense to remove them in these cases. For activity permalinks, it does make sense to have such links (I suppose), but r-a-y is right that it may be a lot of work for a marginal benefit. So, until someone's taken the time to implement it, maybe it makes sense to remove them here too.
Is there a theme-independent way to remove the links? (too lazy to look)
#3
@
11 years ago
- Milestone changed from Awaiting Review to 1.8
- Version set to 1.7
Is there a theme-independent way to remove the links? (too lazy to look)
Yup, they are basically hooked into 'wp_head'
. If we are to remove them, should this code go into the BP_Legacy
class? I think that's the most logical place for this.
Tentatively moving to 1.8.
#4
@
11 years ago
Hi @boonebgorges, @r-a-y
Im agree with you @boonebgorges to remove these prev / next links when on a BuddyPress page. By adding this code somewhere in buddypress core.
function _bp_maybe_remove_adjacent_posts_rel_link_wp_head() { if ( ! bp_is_blog_page() && ! is_404() ) { remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); add_action( 'bp_head', 'bp_adjacent_rel_link_wp_head' , 1); } } add_action( 'wp_head', '_bp_maybe_remove_adjacent_posts_rel_link_wp_head' , 1 );
But I suggest adding rel="next" and rel="prev" in pagination in all buddypress components (members, groups, activity, messages,...etc).
Check this video that talk about SEO and Pagination :
http://www.youtube.com/watch?d&v=njn8uXTWiGg
This can be done by adding a filter to paginate_links wp function :
add_filter('paginate_links', 'bp_add_rel_next_prev_paginate_links',10 , 1 ); function bp_add_rel_next_prev_paginate_links( $pag_links ) { $pag_links = str_replace( '<a class="prev ', '<a rel="prev" class="prev ', $pag_links ); $pag_links = str_replace( '<a class="next ', '<a rel="next" class="next ', $pag_links ); return $pag_links; }
#5
@
11 years ago
megainfo - Thanks for the first function. At a glance, that seems reasonable.
As for the second idea, I like the thought of including rel="prev" etc, but there must be a better way to do it than doing a str_replace(). I don't have time to research it in detail at the moment, but isn't there a way to tell paginate_links() to include these attributes? If not, shouldn't we be offering an upstream patch, since this would make sense for WP too?
#6
@
11 years ago
There is no filter in paginate_links()or param to include these attributs,
i think we need to suggest to wordpress team to add a filter (or a rel="next" rel="prev" attribut to the href with next and prev class).
#7
@
11 years ago
I forget to suggest adding rel="next" to "load more" href in bp default and compact theme.
#8
@
11 years ago
i think we need to suggest to wordpress team to add a filter (or a rel="next" rel="prev" attribut to the href with next and prev class).
Yes. If you open a ticket, please link to it from this thread.
#11
@
10 years ago
- Component changed from All Components to Core
- Keywords has-patch added
- Milestone changed from Future Release to 2.1
Attached patch removes the relational "prev" and "next" links when on a BuddyPress page.
I decided to put this in core since two DB queries are run when WP decides to fetch these links. And we hate additional queries ;)
Here's some documentation on prev / next:
http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#link-type-next
I think this issue becomes more prevalent with BP 1.7 due to the theme compat layer.
However, in order to generate these links we'd need to query for them.
For example, if I'm on an activity permalink page, we'd need to query for the previous and next activity item for that user.
It's a big job for little gain.
My opinion is we should remove these prev / next links when on a BuddyPress page.