BuddyPress Activity Links Open in a New Tab

Not necessarily best practice but here’s the code to filter the BuddyPress activity feed and add target=”_blank” to all the links.

//BUDDYPRESS ACTIVITY FILTER 

function altlab_special_links_activity( $body ) { 
     $body = str_replace(' rel="nofollow"',' rel="nofollow" target="_blank"',$body);

    return $body; 

}
add_filter( 'bp_get_activity_content_body', 'altlab_special_links_activity', 15, 1 );


2 thoughts on “BuddyPress Activity Links Open in a New Tab

  1. I want to cry I am so happy… you know there are posts on buddypress asking for this going back, like over 6 years without a reply. you could be a hero to many

Comments are closed.