Buddypress + WordPress Search

Buddypress steals the WordPress /search slug which means you are limited to ugly permalinks for search. Going to /search would just redirect to the home page with Buddypress installed. After searching the Buddypress code I found this in bp-core-catchuri.php:

// Search doesn't have an associated page, so we check for it separately
if ( !empty( $bp_uri[0] ) && ( bp_get_search_slug() == $bp_uri[0] ) ) {
	$matches[]   = 1;
	$match       = new stdClass;
	$match->key  = 'search';
	$match->slug = bp_get_search_slug();

Since this only executes when the page matches the slug, let’s see how it gets the bp_get_search_slug() in bp-core-template.php:

function bp_get_search_slug() {
	return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );

Show how is the BP_SEARCH_SLUG defined in bp-loader.php:

// The search slug has to be defined nice and early because of the way search requests are loaded
if ( !defined( 'BP_SEARCH_SLUG' ) )
	define( 'BP_SEARCH_SLUG', 'search' );

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *