BBP_Shortcodes::display_search( array $attr, string $content = '' )

Display the contents of search results in an output buffer and return to ensure that post/page contents are displayed first.

Description

Parameters

$attr

(Required)

$content

(Optional)

Default value: ''

Source

File: bp-forums/common/shortcodes.php

691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
public function display_search( $attr, $content = '' ) {
 
    // Sanity check required info
    if ( !empty( $content ) ) {
        return $content;
    }
 
    // Bail if search is disabled
    if ( ! bbp_allow_search() ) {
        return;
    }
 
    // Trim search attribute if it's set
    if ( isset( $attr['search'] ) ) {
        $attr['search'] = trim( $attr['search'] );
    }
 
    // Set passed attribute to $search_terms for clarity
    $search_terms = empty( $attr['search'] ) ? bbp_get_search_terms() : $attr['search'];
 
    // Unset globals
    $this->unset_globals();
 
    // Set terms for query
    set_query_var( bbp_get_search_rewrite_id(), $search_terms );
 
    // Start output buffer
    $this->start( bbp_get_search_rewrite_id() );
 
    // Output template
    bbp_get_template_part( 'content', 'search' );
 
    // Return contents of output buffer
    return $this->end();
}

Changelog

Changelog
Version Description
bbPress (r4579) 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.