Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 模板页面在哪里被调用?_Php_Wordpress - Fatal编程技术网

Php 模板页面在哪里被调用?

Php 模板页面在哪里被调用?,php,wordpress,Php,Wordpress,我正在尝试将wordpress与以前安装的平台集成 我可以随心所欲地编辑大部分系统,但在加载模板文件之前,我不知道如何干预wordpress的工作 我想添加的是一个简单的条件语句,它要么通过我以前的cms加载页面,要么正常加载wordpress 但是,我无法理解哪个函数或文件加载了主题的组件 我知道wp使用模板层次结构,为不同类型的页面(帖子、分类页面等)加载不同的文件 但是,是什么函数做出了这样的选择并实际加载了文件?您的问题还不太清楚,您实际上想做什么,但是/wp includes/temp

我正在尝试将
wordpress
与以前安装的平台集成

我可以随心所欲地编辑大部分系统,但在加载
模板文件之前,我不知道如何干预
wordpress
的工作

我想添加的是一个简单的条件语句,它要么通过我以前的cms加载页面,要么正常加载
wordpress

但是,我无法理解哪个函数或文件加载了主题的组件

我知道
wp
使用模板层次结构,为不同类型的页面(帖子、分类页面等)加载不同的
文件


但是,是什么
函数
做出了这样的选择并实际加载了文件?

您的问题还不太清楚,您实际上想做什么,但是/wp includes/template-loader.php会引起您的特别兴趣

这是加载模板的文件。为了说明这一点,我不是建议你修改这个文件,我只是指出魔法发生的地方

加载后,它将立即运行操作
模板\u重定向
。如果你想执行一些逻辑,那么重定向就是你要做的。下面是主题的functions.php中的一个示例:

function wpse_template_redirect() {
    if ( condition_a() == condition_b() ) {
        wp_redirect( 'url-to-redirect-to' );
        exit;
    }
}
add_action( 'template_redirect', 'wpse_template_redirect' );
在该文件的底部,有一些条件决定了哪个模板文件是:

$template = false;
if     ( is_404()            && $template = get_404_template()            ) :
elseif ( is_search()         && $template = get_search_template()         ) :
elseif ( is_front_page()     && $template = get_front_page_template()     ) :
elseif ( is_home()           && $template = get_home_template()           ) :
elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
elseif ( is_attachment()     && $template = get_attachment_template()     ) :
    remove_filter('the_content', 'prepend_attachment');
elseif ( is_single()         && $template = get_single_template()         ) :
elseif ( is_page()           && $template = get_page_template()           ) :
elseif ( is_category()       && $template = get_category_template()       ) :
elseif ( is_tag()            && $template = get_tag_template()            ) :
elseif ( is_author()         && $template = get_author_template()         ) :
elseif ( is_date()           && $template = get_date_template()           ) :
elseif ( is_archive()        && $template = get_archive_template()        ) :
elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
elseif ( is_paged()          && $template = get_paged_template()          ) :
else :
    $template = get_index_template();
endif;
/**
 * Filter the path of the current template before including it.
 *
 * @since 3.0.0
 *
 * @param string $template The path of the template to include.
 */
if ( $template = apply_filters( 'template_include', $template ) )
    include( $template );
return;