BuddyDev

Search

Shortcode Activity – Limit the activity content

  • Participant
    Level: Initiated
    Posts: 10
    Michel GREGOIRE on #31600

    Hi !

    I need to limit the displayed activity excerpt to 9 words.

    Is it possible to achieve this?

    Best regards

    MG

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #31603

    Hello Michel,

    Thank you for posting. BuddyPress provides a filter to control the excerpt length. Use the following code

    
    /**
     * Modify excerpt length. Return no. of characters in activity excerpt.
     *
     * @param int $length Length.
     *
     * @return int
     */
    function buddydev_modify_excerpt_length( $length ) {
    	$length = 100;
    
    	return $length;
    }
    add_filter('bp_activity_excerpt_length', 'buddydev_modify_excerpt_length' );
    
    

    Please check.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 10
    Michel GREGOIRE on #31605

    Hi Ravi, many thanks for your answer !

    Just a precision, is this code mut be added to function.php, in my active theme folder<?

    Many thanks for your cooperation.

    Michel

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #31613

    Hello Michel,

    You can put this code in ‘bp-custom.php’. Please check the following url

    https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved