Php WordPress:get_header()不包括模板文件中的头
我使用types插件创建了名为clients的自定义post类型,并创建了一个名为clients的页面。为了从客户机文件中的自定义post类型获取数据,我创建了名为clients-template.php的模板,下面是其中的代码Php WordPress:get_header()不包括模板文件中的头,php,wordpress,custom-post-type,Php,Wordpress,Custom Post Type,我使用types插件创建了名为clients的自定义post类型,并创建了一个名为clients的页面。为了从客户机文件中的自定义post类型获取数据,我创建了名为clients-template.php的模板,下面是其中的代码 <?php /** * Template Name: Client Template * * @package WordPress * @subpackage Twenty_Fourteen * @since Twenty Fourteen 1.0 *
<?php
/**
* Template Name: Client Template
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
?>
<?php get_header(); ?>
<div id="main-content" class="main-content">
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
$args=array('post_type' => 'client');
$query= new WP_Query($args);
// Start the Loop.
while ($query-> have_posts() ) : $query->the_post();
echo the_title();
echo the_post_thumbnail();
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->
现在,当我使用此模板添加页面时,我希望它显示标题,然后显示此单独帖子类型的内容,但它不添加标题有什么问题请帮助我
<?php
/**
* Template Name: Client Template
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
get_header();
?>
<div id="main-content" class="main-content">
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
$args=array('post_type' => 'client');
$query= new WP_Query($args);
// Start the Loop.
while ($query-> have_posts() ) : $query->the_post();
echo the_title();
echo the_post_thumbnail();
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->
<?php
get_footer();
?>
主题是否包含
header.php
文件?尝试使用include
函数包含它。是的,模板在页面模板文件夹中,标题在主文件夹中,然后include('../header.php')代码>不要包含包含的标题-WordPress不是这样工作的。get_header()可以在主题的根目录中引入header.php模板。如果它不工作,那么您应该启用调试定义('WP_debug',true);在您的wp-settings.php中,查看是否出现任何错误。您能解释一下这一点吗?有什么不同?这将对原始海报更有帮助。请调用页脚以删除javascript错误。因为有时javascript错误,所以不能正确地sow头。