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

Retrieve path to a template


Description 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 Parameters

$type

(Required) Filename without extension.

$templates

(Optional) An optional list of template candidates

Default value: array()


Top ↑

Return Return

(string) Full path to file.


Top ↑

Source Source

File: includes/core/template-functions.php

function bbp_get_query_template( $type, $templates = array() ) {
	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );

	// Fallback template
	if ( empty( $templates ) ) {
		$templates = array( "{$type}.php" );
	}

	// Filter possible templates
	$templates = apply_filters( "bbp_get_{$type}_template", $templates );

	// Stash the possible templates for this query, for later use
	bbp_set_theme_compat_templates( $templates );

	// Try to locate a template in the stack
	$template = bbp_locate_template( $templates );

	// Stash the located template for this query, for later use
	bbp_set_theme_compat_template( $template );

	// Filter & return
	return apply_filters( "bbp_{$type}_template", $template, $templates );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.