WordPress filter hook
bp_get_template_locations
Fired by 3 WordPress plugins, running on 92K+ sites between them.
“Filters the possible subdirectories to check for templates in.”
How to use bp_get_template_locations
It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'bp_get_template_locations', function( $locations, $templates ) {
// Change $locations here.
return $locations;
}, 10, 2 );Argument names come from BuddyPress's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
3 plugins that fire bp_get_template_locations
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
BuddyPress90,000+ installs
apply_filters( 'bp_get_template_locations', $locations, $templates )bp-core/bp-core-template-loader.php:514 -
BuddyPress Follow1,000+ installs
apply_filters( 'bp_get_template_locations', $locations, $templates )_inc/bp-follow-backpat.php:146 -
BuddyPress Integration for WooCommerce700+ installs
apply_filters( 'bp_get_template_locations', $locations, $templates )class/core/wc4bp-template-compatibility.php:153
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.