2011-10-07 39 views
0

这是我的single.php:如何从Wordpress中的single.php中包含.php文件中发布信息?

<?php get_header(); ?> 
<?php if (have_posts()) : the_post();?> 
    <div id="content"> 
     <?php include('blocks/post_page.php')?> 
     <?php include('blocks/fix_01.php')?> 
     <?php include('blocks/fix_02.php')?> 
    </div> 
<?php endif;?> 

<?php get_footer(); ?> 

这是post_page.php:

<div id="post_page"> 
    <?php include('columna_01_0.php')?> 
    <?php include('columna_02_0.php')?> 

    <div id="single_post_block"> 
     <div class="b_cnt"> 
     <div class="logo_post"></div> 
      <div class="category"> 
       <h2><?php the_category(); ?></h2> 
      </div> 
      <div class="title"> 
       <h1><?php the_title(); ?></h1> 
      </div> 
      <div class="post"> 
       <?php the_content(); ?> 
       <?php comments_template(); ?> 
      </div> 
     </div> 
    </div> 
</div> 

的问题是,它显示刚刚过去的职位信息不要求的文章信息。

如果我把<?php if (have_posts()) : the_post();?>放在post_page.php中没有帖子显示,并且在single.php中使用the_category()the_title()等工作正常。

如何在包含文件中获取此信息?

谢谢。

+0

问题是之前的'includes'之一是对帖子作出了不同的查询,因此分类查询被清除。谢谢你所有,并要小心这个;-) – francadaval

+0

https://codex.wordpress.org/Function_Reference/$post – 2017-02-24 13:29:45

回答

相关问题