bp_get_query_template( string $type, array $templates = array() )
Retrieve the path to a template.
Description
Used to quickly retrieve the path of a template without including the file extension. It will also check the parent theme and theme-compat theme with the use of bp_locate_template(). Allows for more generic template locations without the use of the other get_*_template() functions.
Parameters
- $type
-
(Required) Filename without extension.
- $templates
-
(Optional) An optional list of template candidates.
Default value: array()
Return
(string) Full path to file.
Source
File: bp-core/bp-core-template-loader.php
function bp_get_query_template( $type, $templates = array() ) {
$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
if ( empty( $templates ) ) {
$templates = array( "{$type}.php" );
}
/**
* Filters possible file paths to check for for a template.
*
* This is a variable filter based on the type passed into
* bp_get_query_template.
*
* @since BuddyPress 1.7.0
*
* @param array $templates Array of template files already prepared.
*/
$templates = apply_filters( "bp_get_{$type}_template", $templates );
// Filter possible templates, try to match one, and set any BuddyPress theme
// compat properties so they can be cross-checked later.
$templates = bp_set_theme_compat_templates( $templates );
$template = bp_locate_template( $templates );
$template = bp_set_theme_compat_template( $template );
/**
* Filters the path to a template file.
*
* This is a variable filter based on the type passed into
* bp_get_query_template.
*
* @since BuddyPress 1.7.0
*
* @param string $template Path to the most appropriate found template file.
*/
return apply_filters( "bp_{$type}_template", $template );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.7.0 | 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.