Use a custom excerpt in the Activity Stream for blog posts

Sometimes you want to have full control over the excerpt that is shown in the activity stream when you publish a new post for your readers. R-A-Y from BuddyPress.org has created a simple snippet which gives you back control over how the excerpt will be displayed in new Blog Post entries. Here’s the code:

Place the following in your child themes functions.php file, or in bp-custom.php:

function my_bp_post_excerpt($activity_content, $post, $permalink) {
if($post->post_excerpt)
return $post->post_excerpt;
else
return $activity_content;
}
add_filter( 'bp_blogs_activity_new_post_content', 'my_bp_post_excerpt', 1, 3 );

Done!

BuddyPress Hosting Guide Looking for quality BuddyPress hosting? We will guide you through all the available hosting options and help you find the best webhost for your next BuddyPress project!

Something about bowe

BuddyPress fanatic, WordPress Theme designer and MultiSite community builder. Proud co-founder of PressCrew. Loves to use awesome in every sentence. Often described as a Dutch Treehugging Hippie.

6 Responses to Use a custom excerpt in the Activity Stream for blog posts

  1. Oli November 15, 2010 at 3:15 pm #

    thx, exactly what i needed!

    Reply
  2. bowe November 17, 2010 at 11:24 pm #

    your welcome!

    Reply
  3. Tahir July 16, 2011 at 4:41 pm #

    I am a lover of buddypress . i have a question please give me a suggestion. whenever a user publish a new blog post , full post is displayed in activity stream. if a post is lengthy it does not looks good in activity stream. i want to to display a paragraph or just title of lengthy post in activity stream instead of full post. how can i do that.

    Reply
  4. mrjarbenne September 9, 2011 at 2:39 am #

    Is there a way to change the activity content excerpt: shorten, lengthen, or remove it entirely if you only wanted to blog title to show up in the activity feed. I assume it might be done with some variation of this code, replacing the else return activity_content with none somehow.

    Reply
  5. dainis w michel December 18, 2011 at 10:12 pm #

    added to functions.php and all posts appeared blank.

    Reply

Trackbacks/Pingbacks

  1. BuddyPress Tutorial Roundup: 15 Useful Hacks and Customizations - WPMU.org - May 14, 2013

    [...] View Tutorial [...]

Leave a Reply