bp_search_result_intro( $content, int $character_limit = 50 )
Returns highlighted search keyword and trimmed content string with
Description
Parameters
- $content
-
(Required)
- $character_limit
-
(Optional)
Default value: 50
Return
(mixed|void)
Source
File: bp-search/bp-search-functions.php
function bp_search_result_intro( $content, $character_limit = 50 ) { $content = wp_strip_all_tags( $content, true ); $search_term = BP_Search::instance()->search->get_search_term(); $search_term_position = stripos( $content, $search_term ); if ( $search_term_position !== false ) { $shortened_content = '…' . substr( $content, $search_term_position, $character_limit ); //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_result_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.