-
Author
Tagged: limit excerpt
-
November 18, 2014 at 13:02 #35859KookidookiParticipant
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 CODEif ( ! 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>'; } }
November 19, 2014 at 02:55 #35950KamalModeratorHi,
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 solutionNovember 19, 2014 at 19:44 #35986KookidookiParticipantHi 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?
November 20, 2014 at 20:24 #36121KamalModeratorHi,
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 CODEfunction 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,
KamalHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionNovember 20, 2014 at 23:09 #36142KookidookiParticipantHey Kamal,
It doesn’t work unfortunately.
Thanks.
November 20, 2014 at 23:22 #36143KamalModeratorHi,
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.
KamalHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.