bp_search_reply_intro( $character_limit = 50 )
Returns a trimmed reply content string.
Description
Works for replies as well as topics. Must be used while inside the loop
Source
File: bp-search/bp-search-functions.php
function bp_search_reply_intro( $character_limit = 50 ) { $content = ''; switch ( get_post_type( get_the_ID() ) ) { case 'topic': $reply_content = bbp_get_topic_content( get_the_ID() ); break; case 'reply': $reply_content = bbp_get_reply_content( get_the_ID() ); break; default: $reply_content = get_the_content(); break; } if ( $reply_content ) { $content = wp_strip_all_tags( $reply_content, true ); $search_term = BP_Search::instance()->get_search_term(); $search_term_position = stripos( $content, $search_term ); if ( $search_term_position !== false ) { $shortened_content = bp_search_result_match( $content, $search_term ); //highlight search keyword $shortened_content = str_ireplace( $search_term, "<strong>" . $search_term . "</strong>", $shortened_content ); } else { $shortened_content = substr( $content, 0, $character_limit ); if ( strlen( $content ) > $character_limit ) { $shortened_content .= '…'; } } $content = $shortened_content; } return apply_filters( 'bp_search_reply_intro', $content ); }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.