Tagged: activity shortcode, length, word
Hello Yuriix,
Thank you for posting here. There is no attribute supported by plugin to limit no. of words in an activity. But you can use the filter name ‘bp_activity_excerpt_length’ to limit the character count.
If you need assistance with the code Please let me know.
Regards
RaviHello Yuriix,
Please use the following code:
/** * Excerpt length of activity in shortcode context * * @param int $length No. of words. * * @return int */ function buddydev_modify_activity_excerpt_length( $length ) { return 150; } add_action( 'bp_activity_stream_shortcode_before_generate_content', function() { add_filter( 'bp_activity_excerpt_length', 'buddydev_modify_activity_excerpt_length' ); } ); add_action( 'bp_activity_stream_shortcode_after_generate_content', function () { remove_filter( 'bp_activity_excerpt_length', 'buddydev_modify_activity_excerpt_length', 10 ); } );
Please let me know if it helps or not.
Regards
RaviHello Keymaster,
Cool, it works perfectly if the user adds something via Activity. Unfortunately, if I add a post, the text is still long.Regards
Hello Yuriix,
Please try to use the following code:
/** * Excerpt length of activity in shortcode context * * @param int $length No. of words. * * @return int */ function buddydev_modify_activity_excerpt_length( $length ) { return 50; } add_action( 'bp_activity_stream_shortcode_before_generate_content', function() { add_filter( 'bp_activity_maybe_truncate_entry', '__return_true' ); add_filter( 'bp_activity_excerpt_length', 'buddydev_modify_activity_excerpt_length', 100 ); } ); add_action( 'bp_activity_stream_shortcode_after_generate_content', function () { remove_filter( 'bp_activity_maybe_truncate_entry', '__return_true', 10 ); remove_filter( 'bp_activity_excerpt_length', 'buddydev_modify_activity_excerpt_length', 100 ); } );
Please let me know if it helps you or not.
Regards
Ravi
The topic ‘ [Resolved] BuddyPress Activity Shortcode – Set length (word count) of the text’ is closed to new replies.