BuddyDev

Search

[Resolved] Adjusting length of text before Read More link

  • Participant
    Level: Enlightened
    Posts: 31
    Dale Reardon on #21666

    Hi,
    I am sure there must be a setting somewhere, surely, but I can’t find it.

    In some of our activity posts BP inserts a Read More link after a certain number of characters. We want to increase the number of characters displayed initially so not as many posts have a read more link.

    How can this be adjusted?

    Thanks,
    Dale.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #21685

    HI Dale,
    This should most probably work

    
    
    /**
     * Change length of activity excerpt.
     *
     * @param int $length length.
     *
     * @return int
     */
    function buddydev_change_activity_excerpt_length( $length ) {
    	return 500;
    }
    
    add_filter( 'bp_activity_excerpt_length', 'buddydev_change_activity_excerpt_length' );
    
    

    Please give it a try and let me know.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 27
    Vict0rl0pez on #44653

    This code should be added to what file???

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #44659

    Hello Dale,

    Use this code either in your active theme ‘functions.php’ file or ‘bp-custom.php’ file.

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

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 27
    Vict0rl0pez on #44669

    It wasn’t Dale, it was me @vict0rl0pez, but cleared up and also grateful 😊

  • Participant
    Level: Enlightened
    Posts: 27
    Vict0rl0pez on #44670

    I have created the bp-custom.php in wp-content/plugin, I have tried in the theme’s functions.php and in the buddypress-functions.php in /wp-content/themes/community-builder/buddypress, but all of it It gives me an error and blocks me from accessing the page.
    Do you know what it could be due to?
    Thank you very much again.

    • This reply was modified 2 years, 6 months ago by Vict0rl0pez.
  • Participant
    Level: Enlightened
    Posts: 27
    Vict0rl0pez on #44680

    A mí, no me funciona.
    ¿Puede haber cambiado algo durante estos 2 años, que puede ser ?
    Gracias.

  • Participant
    Level: Enlightened
    Posts: 27
    Vict0rl0pez on #44684

    even on this route, I have found something that could seem to work … but no !!!

    /wp-content/themes/community-builder/includes/buddypress/cb-bp-hooks.php

    🙁

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #44685

    Hi Victor,
    I am sorry for the trouble.

    1. When creating a bp-custom.php, Please make sure the opening php tags are present.

    Here is an example, that you can copy directly.

    https://gist.githubusercontent.com/sbrajesh/55639df69806b564a9765562a4f40e37/raw/e58379a5598d075b0475aa734b68281b5328fe3f/bp-custom.php

    2. Please make sure you have not put the code anywhere else as you can not have 2 copies.

    Please do that and let me know.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 27
    Vict0rl0pez on #44693

    I haven’t had time to put your message into practice yet, thank you very much.
    Meanwhile I have found the code that YES it has done.

    /**
     * Show all activity content instead of the trimmed content with read more.
     */
    function buddydev_show_all_activity_content() {
        remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
        remove_filter( 'bp_get_activity_content',      'bp_activity_truncate_entry', 5 );
    }
     
    add_action( 'bp_init', 'buddydev_show_all_activity_content' );
    add_action( 'bp_activity_sent_reply_to_reply_notification', 'buddydev_show_all_activity_content' );

    Really thanks for the help and speed!

    • This reply was modified 2 years, 6 months ago by Vict0rl0pez.
    • This reply was modified 2 years, 6 months ago by Vict0rl0pez.
    • This reply was modified 2 years, 6 months ago by Vict0rl0pez.
    • This reply was modified 2 years, 6 months ago by Vict0rl0pez.

The topic ‘ [Resolved] Adjusting length of text before Read More link’ is closed to new replies.

This topic is: resolved