bbp_get_query_template( string $type, array $templates = array() )
Retrieve 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 bbp_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-forums/core/template-functions.php
function bbp_get_query_template( $type, $templates = array() ) {
$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
if ( empty( $templates ) )
$templates = array( "{$type}.php" );
// Filter possible templates, try to match one, and set any Forums theme
// compat properties so they can be cross-checked later.
$templates = apply_filters( "bbp_get_{$type}_template", $templates );
$templates = bbp_set_theme_compat_templates( $templates );
$template = bbp_locate_template( $templates );
$template = bbp_set_theme_compat_template( $template );
return apply_filters( "bbp_{$type}_template", $template );
}
Changelog
| Version | Description |
|---|---|
| bbPress (r3629) | 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.