This topic has 5 replies, 2 voices, and was last updated 10 years by Kamal.

  • Author

    Tagged: 

  • #35859
     Kookidooki
    Participant

    Hey guys, developers,

    How do I limit the displayed words (e.g. 20 words) in the groups overview?

    Have tried this code in functions.php of child-theme:

    COPY CODE
    if ( ! function_exists( 'kleo_excerpt' ) )
    {
        function kleo_excerpt( $limit = 20 ) {
            $excerpt = explode( ' ', get_the_excerpt(), $limit );
            if ( count( $excerpt ) >= $limit ) {
                array_pop( $excerpt );
                $excerpt = implode( " ", $excerpt ) . '...';
            } else {
                $excerpt = implode( " ", $excerpt ) . '';
            }
            $excerpt = preg_replace( '<code>\[[^\]]*\]</code>', '', $excerpt );
            return '<p>' . $excerpt . '</p>';
        }
    } 
    #35950
     Kamal
    Moderator

    Hi,
    You can try with the following code. Please insert this code to the functions.php in Kleo child theme.

    COPY CODE
    
    // limit group description length 
    function my_excerpt_group_description( $description ) {
    
      $length = 20;
      $description = substr($description,0,$length);
      return $description;
    }
    add_filter( 'bp_get_group_description', 'my_excerpt_group_description');
    

    then save the file and refresh the page. If you want more functionality for handling group descrioption, You can give this plugin a try. It will definitely get the job done. But unfortunately it is a paid plugin. If you have any question, please feel free to ask me anytime.
    Thanks.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #35986
     Kookidooki
    Participant

    Hi Kamal,

    Thanks, but this is about the description of a group.

    What I want is a modification in the group overview description, e.g. group masonry.
    When you hit “Groups Overview” in your menu you will see an overview of your created groups with description. I want to limit the description to 20 words to save space.

    Any idea?

    #36121
     Kamal
    Moderator

    Hi,
    Your problem is completely related to buddypress plugin as buddypress plugin outputs the excerpt for the group description. So you can get best solution if you ask about your problem in their forum. However, if you can afford buying a plugin, then the previous plugin will definitely get the job done. and you can also try with following code. I found this on buddypress forum.

    COPY CODE
    
    function bp_excerpt_group_description( $description ) {
    
    // your exceprt code
     $length = 30;// change it to whatever length you prefer
     $description = substr($description,0,$length);
     return $description;
    }
    
    add_filter( ‘bp_get_group_description_excerpt’, ‘bp_excerpt_group_description’);
    

    Thanks,
    Kamal

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #36142
     Kookidooki
    Participant

    Hey Kamal,

    It doesn’t work unfortunately.

    Thanks.

    #36143
     Kamal
    Moderator

    Hi,
    I am sorry I did not work. I tried my best to help you but the issue is completely related to buddypress plugin. Perhaps, You can follow the alternative solution I mentioned in my previous message to get best solution. If you have any question related to our theme, please ask me anytime.
    Thank you very much.
    Kamal

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?