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 Description


Parameters Parameters

$attr

(Required)

$content

(Optional)

Default value: ''


Top ↑

Source Source

File: includes/common/shortcodes.php

	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();
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.