Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Change lengt of blog posts title ?


fishbowl81
Participant

@fishbowl81

This maybe a good starting point for you

/**

* bp_create_excerpt()

*

* Fakes an excerpt on any content. Will not truncate words.

*

* @package BuddyPress Core

* @param $text str The text to create the excerpt from

* @uses $excerpt_length The maximum length in characters of the excerpt.

* @return str The excerpt text

*/

function bp_create_excerpt( $text, $excerpt_length = 55, $filter_shortcodes = true ) { // Fakes an excerpt if needed

$text = str_replace(‘]]>’, ‘]]>’, $text);

$text = strip_tags($text);

if ( $filter_shortcodes )

$text = preg_replace( ‘|\[(.+?)\](.+?\[/\\1\])?|s’, ”, $text );

$words = explode(‘ ‘, $text, $excerpt_length + 1);

if (count($words) > $excerpt_length) {

array_pop($words);

array_push($words, ‘[…]’);

$text = implode(‘ ‘, $words);

}

return stripslashes($text);

}

Skip to toolbar