Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change lengt of blog posts title ?

  • Avatar of Seppolaatle112
    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)
  • Avatar of Fishbowl81
    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);

    }

    Avatar of BingoNeighbour
    BingoNeighbour
    Participant

    @bingoneighbour

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

    Avatar of barhands
    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)

You must be logged in to reply to this topic.