Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change lengt of blog posts title ?


  • seppolaatle112
    Participant

    @seppolaatle112

    Hi and hello again…

    Is there any way I can change the lenght of the posts title appearing with a widget on the front page? Sometimes it’s bad when someone write a new post with a title containing something like 150 words..

    Thanks in advance. :)

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

  • 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);

    }


    bingoneighbour
    Participant

    @bingoneighbour

    In theory, could this be used on group pages too?


    Deli Yaban
    Participant

    @leventyilmaz

    can you please explain a little bit more…where should I put this code? Im not an expert in php..

    could this be used for profile>Blogs>Recent Blogs ?

    thx for your help

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change lengt of blog posts title ?’ is closed to new replies.
Skip to toolbar