Skip to:
Content
Pages
Categories
Search
Top
Bottom

Recent Site Wide Posts & blog posts in activity : limit excerpt


  • grosbouff
    Participant

    @grosbouff

    Hi, I would like to change how are displayed the posts in the Recent Site Wide Posts widgets; and in the Blogs Activity Stream :

    Hi would like to show only text (no images) and limit them to XX chars.

    How can I do this ?

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

  • danbpfr
    Participant

    @chouf1

    Hi,

    Things happens here for text:

    buddypress 1.1.1\bp-core\bp-core-templatetags.php

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

    In the same file you probably find some code for avatar


    grosbouff
    Participant

    @grosbouff

    Here’s what I did :

    function my_excerpts($content = false) {

    // If is the home page, an archive, or search results

    //if(is_front_page() || is_archive() || is_search()) :

    $content = strip_shortcodes($content);

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

    $content = strip_tags($content);

    $excerpt_length = 20;

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

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

    array_pop($words);

    array_push($words, ‘…’);

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

    endif;

    $content = ‘<p>’ . $content . ‘</p>’;

    //endif;

    // Make sure to return the content

    return $content;

    }

    add_filter(‘bp_create_excerpt’, ‘my_excerpts’);

    (it works, but I don’t know how to limit this to the activity only….well, I don’t need it for the moment.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Recent Site Wide Posts & blog posts in activity : limit excerpt’ is closed to new replies.
Skip to toolbar