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

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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 .= '&hellip;';
            }
        }
 
        $content = $shortened_content;
    }
 
    return apply_filters( 'bp_search_reply_intro', $content );
}

Changelog

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.