Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to override core function?


  • James
    Participant

    @janismo

    hi,

    I am trying to take control over function “bp_activity_truncate_entry”.
    I am interested to change line “$excerpt_length = apply_filters( ‘bp_activity_excerpt_length’, 358 );” from functions.php or bp-custom.php, but cannot achieve this.

    Any professional advice?

    thak you!

Viewing 4 replies - 1 through 4 (of 4 total)

  • @ChrisClayton
    Participant

    @chrisclayton

    So, you want to change the 358?
    you can do that with something like this

    function cc_custom_excerpt_length() {
    return '20';
    }
    add_filter( 'bp_activity_excerpt_length', 'cc_custom_excerpt_length' );

    Using that will change the activity excerpt length to 20.

    Disclaimer: i am not a professional and this is not advice.


    James
    Participant

    @janismo

    thanks @chrisclayton! using your method I’ve been able to modify read more link too, but how could I hook into $excerpt = bp_create_excerpt( $text, $excerpt_length, array( 'ending' => __( '…', 'buddypress' ) ) ); to change ending text ‘…’?


    @ChrisClayton
    Participant

    @chrisclayton

    This line’s controlling it.
    $ending = apply_filters( 'bp_excerpt_append_text', $ending );

    So, we want to use

    function cc_excerpt_append_text() {
    return 'Stop Reading';
    }
    add_filter( 'bp_excerpt_append_text', 'cc_excerpt_append_text' );

    Again, just change ‘Stop Reading’ to whatever you want to replace it.


    @ChrisClayton
    Participant

    @chrisclayton

    BTW. If you’d like to read more about filters – this one’s a great one. While it’s focused on themes, it’s the exact same theory :)
    Using Filter Hooks in WordPress Child Themes

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to override core function?’ is closed to new replies.
Skip to toolbar