2012-08-30 48 views
0

有没有简单的方法来改变WP的默认模板层次?更改WordPress的模板层次

例如;

说我要改变我的主题目录结构,使其完全从模板层次改变这里建议基于条件句:

http://codex.wordpress.org/Template_Hierarchy

,如果我想,以确保所有的页面类型(is_single()is_home()等)它总是打开一个模板文件,然后煽动我自己的模式提供输出?

非常感谢!

+1

请勿重复提问:http://wordpress.stackexchange.com/questions/63614/changing-the-template-hierarchy – janw

回答

1

我会做这样的: 易于阅读和行之有效的

的single.php:

<?php include_once('template-you-want.php'); 

home.php:

<?php include_once('template-you-want.php'); 

如果你不想要有这两个文件在index.php做:

<?php 
// at the very top 
if (is_single()){ 
    include_once('template-you-want.php'); 
    die(); // don't continue 
} 

if (is_home()){ 
    include_once('template-you-want.php'); 
    die(); // don't continue 
}