Skip to:
Content
Pages
Categories
Search
Top
Bottom

Limit title characters


  • stefan
    Participant

    @svelsas

    Hi There,

    I want to limit the characters on a title:
    When i run a substr( bp_the_topic_title(),0,50);) it doesnt strip the characters. I think because the function bp_the_topic_title() echo’s it straight away.

    Is there a fix to do this?

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

  • stefan
    Participant

    @svelsas

    Anyone?


    ElevenTwenty2
    Member

    @eleventwenty2

    bump on this.


    ElevenTwenty2
    Member

    @eleventwenty2

    Here’s what I came up with and it works the way I need it..

    I added the following function to the “buddypress/bp-forums/bp-forums-templatetags.php” file.

    `function bp_the_short_topic_title() {
    echo bp_get_the_short_topic_title();
    }
    function bp_get_the_short_topic_title() {
    global $forum_template;
    $topic = $forum_template->topic->topic_title;

    if (strlen($topic) > 35)
    {
    $output = substr($topic, 0, 35).’…’;
    }
    else
    {
    $output = $forum_template->topic->topic_title;
    }
    return apply_filters( ‘bp_get_the_topic_title’, stripslashes($output) );
    }`

    then just replaced bp_the_topic_title() with bp_the_short_topic_title() where I needed it shortened.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limit title characters’ is closed to new replies.
Skip to toolbar