bbp_get_search_results_url()

Return the search url

Description

Return

(string) Search url

Source

File: bp-forums/search/template.php

303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
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.