bbp_get_search_results_url()

Return the search url

Description

Return

(string) Search url

Source

File: bp-forums/search/template.php

	function bbp_get_search_results_url() {
		global $wp_rewrite;

		// Get the search terms
		$search_terms = bbp_get_search_terms();

		// Pretty permalinks
		if ( $wp_rewrite->using_permalinks() ) {

			// Root search URL
			$url = $wp_rewrite->root . bbp_get_search_slug();

			// Append search terms
			if ( !empty( $search_terms ) ) {
				$url = trailingslashit( $url ) . user_trailingslashit( urlencode( $search_terms ) );
			}

			// Run through home_url()
			$url = home_url( user_trailingslashit( $url ) );

		// Unpretty permalinks
		} else {
			$url = add_query_arg( array( bbp_get_search_rewrite_id() => urlencode( $search_terms ) ), home_url( '/' ) );
		}

		return apply_filters( 'bbp_get_search_results_url', $url );
	}

Changelog

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