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
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 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.