Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to override core function?

  • Avatar of James
    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)
  • Avatar of @ChrisClayton
    @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.

    Avatar of James
    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 ‘…’?

    Avatar of @ChrisClayton
    @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.

    Avatar of @ChrisClayton
    @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 :)

    http://themeshaper.com/2009/05/03/filters-wordpress-child-themes/

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

You must be logged in to reply to this topic.