So I think I found the part that creates / modifies the excerpt. It is in bp-core-template.php. Starting at line 353.
`/**
* Truncates text.
*/
function bp_create_excerpt( $text, $length = 225, $options = array() ) {
// Backward compatibility. The third argument used to be a boolean $filter_shortcodes
$filter_shortcodes_default = is_bool( $options ) ? $options : true;
$defaults = array(
‘ending’ => __( ‘ […]’, ‘buddypress’ ),
‘exact’ => false,
‘html’ => true,
‘filter_shortcodes’ => $filter_shortcodes_default
);
$r = wp_parse_args( $options, $defaults );
extract( $r );
// Save the original text, to be passed along to the filter
$original_text = $text;
// Allow plugins to modify these values globally
$length = apply_filters( ‘bp_excerpt_length’, $length );
$ending = apply_filters( ‘bp_excerpt_append_text’, $ending );
// Remove shortcodes if necessary
if ( $filter_shortcodes )
$text = strip_shortcodes( $text );`
`remove_filter( ‘bp_create_excerpt’, $length, $options );
function pnb_excerpt(){
$lenght = 500;
$options = array(
‘ending’ => __( ‘ […]’, ‘buddypress’ ),
‘exact’ => false,
‘html’ => false,
‘filter_shortcodes’ => $filter_shortcodes_default);
return apply_filters( ‘bp_create_excerpt’, $length, $options );
}`
I also tried with apply_filter, and without the remove_filter.
How do I overwrite the defaults? (The $length, and the $options array).
Thanks in advance,
Ruud
Not sure why but this forum keeps cutting out links / random parts of my post.
The second piece should be, for the content above to make sense:
`remove_filter( ‘bp_create_excerpt’, $length, $options );
function pnb_excerpt(){
$lenght = 500;
$options = array(
‘ending’ => __( ‘ […]’, ‘buddypress’ ),
‘exact’ => false,
‘html’ => false,
‘filter_shortcodes’ => $filter_shortcodes_default);
}
add_filter( ‘bp_create_excerpt’, $length, $options );
`
Either way tried both of them.
Thanks,
Ruud
see also the function bp_activity_truncate_entry in bp-activity-filters.php
Thanks for your help. But I am confused, I don’t seem to be able to apply the filters?
I tried `apply_filters (‘bp_activity_excerpt_length’, 500);` which doesn’t make a difference. If I try it with add_filter it gives unexpected value error.
BTW what is the difference between the excerpt length from bp_activity_truncate_entry and the excerpt length from bp_create_excerpt? Is the first one solely for the activity stream?
Same goes for bp_activity_excerpt_append_text vs. bp_excerpt_append_text.
Thanks for your help,
Ruud