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.


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 );

Comments on this post

  1. tripvendors said on March 22, 2019 at 5:12 am

    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

  2. joergelp said on March 23, 2019 at 5:56 am

    Awesome as always!!!