Introduce new get_generic_template() function for themes to use to bring in pieces of template.
Use in twentyten for loop.php including. See #9015. git-svn-id: http://svn.automattic.com/wordpress/trunk@13146 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -93,6 +93,35 @@ function get_sidebar( $name = null ) {
|
||||
load_template( get_theme_root() . '/default/sidebar.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a generic template.
|
||||
*
|
||||
* Includes the named template for a theme or if a name is specified then a
|
||||
* specialised template will be included. If the theme contains no {slug}.php file
|
||||
* then no template will be included.
|
||||
*
|
||||
* For the parameter, if the file is called "{slug}-special.php" then specify
|
||||
* "special".
|
||||
*
|
||||
* @uses locate_template()
|
||||
* @since 3.0.0
|
||||
* @uses do_action() Calls 'get_generic_template_{$slug}' action.
|
||||
*
|
||||
* @param string $slug The slug name for the generic template.
|
||||
* @param string $name The name of the specialised template.
|
||||
*/
|
||||
function get_generic_template( $slug, $name = null ) {
|
||||
do_action( "get_generic_template_{$slug}", $name );
|
||||
|
||||
$templates = array();
|
||||
if ( isset($name) )
|
||||
$templates[] = "{$slug}-{$name}.php";
|
||||
|
||||
$templates[] = "{$slug}.php";
|
||||
|
||||
locate_template($templates, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display search form.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user