WordPress: get_header() not including header in te

2019-08-08 23:27发布

i created custom post type called clients using types plugin, and created a page for that called Clients. To fetch data from custom post types in clients file i created template called clients-template.php and here is the code in that

<?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 -->

now when i add page using this template i expect it to show header and then content form this sepecific post type but it does not add header whats wrong pleas help me with it

1条回答
在下西门庆
2楼-- · 2019-08-08 23:51
<?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();
?>
查看更多
登录 后发表回答