Skip to:
Content

Opened 2 years ago

Closed 10 months 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: 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)

4981.01.patch (1004 bytes) - added by r-a-y 11 months ago.

Download all attachments as: .zip

Change History (14)

comment:1 @r-a-y2 years ago

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.

comment:2 @boonebgorges2 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)

comment:3 @r-a-y2 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.

comment:4 @megainfo2 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;
}

comment:5 @boonebgorges2 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?

comment:6 @megainfo2 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).

Last edited 2 years ago by megainfo (previous) (diff)

comment:7 @megainfo2 years ago

I forget to suggest adding rel="next" to "load more" href in bp default and compact theme.

comment:8 @boonebgorges2 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.

comment:9 @megainfo2 years ago

I was open a ticket in wordpress trac

https://core.trac.wordpress.org/ticket/24375

comment:10 @boonebgorges23 months ago

  • Milestone changed from 1.8 to Future Release

comment:11 @r-a-y11 months 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 ;)

Last edited 11 months ago by r-a-y (previous) (diff)

@r-a-y11 months ago

comment:12 @DJPaul10 months ago

  • Keywords commit added

Looks good

comment:13 @r-a-y10 months ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 8511:

Remove "prev" and "next" links when on a BuddyPress page.

WordPress injects these links in the <head> of each WordPress post.
However, BuddyPress doesn't adhere to these links. These links also take
two DB queries on each page load and are uncached.

Therefore, this commit removes these links.

Fixes #4981.

Note: See TracTickets for help on using tickets.