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:
parent
3284d920c0
commit
067e66c8f6
|
@ -17,7 +17,7 @@
|
|||
|
||||
<?php rewind_posts(); ?>
|
||||
|
||||
<?php include 'loop.php'; ?>
|
||||
<?php get_generic_template( 'loop', 'archive' ); ?>
|
||||
|
||||
</div><!-- #content -->
|
||||
</div><!-- #container -->
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<?php rewind_posts(); ?>
|
||||
|
||||
<?php include 'loop.php'; ?>
|
||||
<?php get_generic_template( 'loop', 'author' ); ?>
|
||||
|
||||
</div><!-- #content -->
|
||||
</div><!-- #container -->
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<?php rewind_posts(); ?>
|
||||
|
||||
<?php include 'loop.php'; ?>
|
||||
<?php get_generic_template( 'loop', 'category' ); ?>
|
||||
|
||||
</div><!-- #content -->
|
||||
</div><!-- #container -->
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div id="content">
|
||||
|
||||
<?php if ( have_posts() ) :
|
||||
include 'loop.php';
|
||||
get_generic_template( 'loop', 'index' );
|
||||
else : ?>
|
||||
<h2><?php _e( 'Not Found', 'twentyten' ); ?></h2>
|
||||
<div class="entry-content">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<h1 class="page-title"><?php _e( 'Search Results for: ', 'twentyten' ); ?><span><?php the_search_query(); ?></span></h1>
|
||||
<?php include 'loop.php'; ?>
|
||||
<?php get_generic_template( 'loop', 'search' ); ?>
|
||||
<?php else : ?>
|
||||
<div id="post-0" class="post no-results not-found">
|
||||
<h2 class="entry-title"><?php _e( 'Nothing Found', 'twentyten' ); ?></h2>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<?php rewind_posts(); ?>
|
||||
|
||||
<?php include 'loop.php'; ?>
|
||||
<?php get_generic_template( 'loop', 'tag' ); ?>
|
||||
|
||||
</div><!-- #content -->
|
||||
</div><!-- #container -->
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue