bbp_get_query_template

Retrieve path to a template.

Description

(string) bbp_get_query_template( (string) $type, (array) $templates = array() ); 

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 . Allows for more generic template locations without the use of the other get_*_template() functions.

Returns (string)

Full path to file.

Parameters (2)

0. $type (string)
Filename without extension.
1. $templates — Optional. (array) => array()
An optional list of template candidates

Usage

  1. if ( !function_exists( 'bbp_get_query_template' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/core/template-functions.php'; 
  3.  
  4. // Filename without extension. 
  5. $type = ''; 
  6.  
  7. // An optional list of template candidates 
  8. $templates = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_get_query_template($type, $templates); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/core/template-functions.php  
  1. function bbp_get_query_template( $type, $templates = array() ) { 
  2. $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); 
  3.  
  4. if ( empty( $templates ) ) 
  5. $templates = array( "{$type}.php" ); 
  6.  
  7. // Filter possible templates, try to match one, and set any bbPress theme 
  8. // compat properties so they can be cross-checked later. 
  9. $templates = apply_filters( "bbp_get_{$type}_template", $templates ); 
  10. $templates = bbp_set_theme_compat_templates( $templates ); 
  11. $template = bbp_locate_template( $templates ); 
  12. $template = bbp_set_theme_compat_template( $template ); 
  13.  
  14. return apply_filters( "bbp_{$type}_template", $template );