buddypress: how do i make the group description excerpt shorter?
-
I set up a theme in buddypress and i want to have a teaser section for my groups on there. It works fine but i have a problem to shorten the group description... I'm using it like this: <p><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a></p> <p><?php bp_group_description_excerpt() ?></p> If thereĀ“s a very long group-description it crashes my layout. Is it possible (like in wordpress) to make the excerpt shorter (with a function or something)? Like "maximum of 20 letters", or something like that? Thanks.
-
Answer:
Custom API Write a normal API wrapper function for it and place it in your functions.php theme or offer it as (mu-)plugin. Trim Words /** * Trim Words Cb fn * @link Adjusted from http://snipplr.com/view.php?codeview&id=20397 * * @param string $excerpt Input string * @param int $count Word count * @param boolean/string $more Whether to show a "more" or not or a string * @return string $excerpt */ function wpse50198_word_trim( $excerpt, $limit, $more = FALSE ) { $output = explode( ' ', $excerpt ); $count = count( $input ); if ( $limit < $count ) ) array_splice( $excerpt, $count, null, $output ); if ( $more ) $output .= $more; $output = implode( ' ', $output ); return $output; } The Template Tag /** * * @param bool $count Number of words to show - (default) 20 * @param boolean/string $more Whether to show a "more" or not - (default) ... * @param bool $echo Print or return the excerpt - (default) TRUE * @return string $excerpt The reduced excerpt */ function short_bp_group_descr_excerpt( $count = 20, $more = '&hellip', $echo = TRUE ) { $excerpt = bp_get_group_description_excerpt(); $length = str_word_count( $excerpt ); if ( $count < $length ) $excerpt = wpse50198_trim_words( $excerpt, $count, $more ); if ( $echo ) echo $excerpt; return $excerpt; } Usage Now, just call it like any template tag inside your template: short_bp_group_descr_excerpt();.
Brayaz Zayarb at WordPress Visit the source
Related Q & A:
- How can I make a group in Yahoo 360?Best solution by info.yahoo.com
- How do i make someone a moderator of my Yahoo group?Best solution by Yahoo! Answers
- How do i make my myspace profile shorter?Best solution by Yahoo! Answers
- How do I make a group on Facebook?Best solution by Yahoo! Answers
- How do I make a group contact list?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.