Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Limiting excerpts in the site-wide activity widget


dpolant
Participant

@dpolant

Here is one way to do it I believe. Put this filter and function inside a plugin or your custom.php.

add_filter('bp_blogs_activity_new_post', 'my_process', 2, 3 );

function my_process($activity_content, $post, $post_permalink){

$activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
$activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content, 25 ) . "</blockquote>";

return $activity_content;
}

I think this is the most efficient way of doing this. Basically, this code snippet overrides the content of the activity notification for a new blog entry. It is unfortunate that you have to write all the other crap again, but as you can see the thing you want to change (bp_create_excerpt) doesn’t have its own filter.

The good news is, unlike some approaches to this problem, this solution doesn’t require that you alter the core.

Try it and see if it works. Sorry ’bout the layout overflow :(

Skip to toolbar