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()
等工作正常。
如何在包含文件中獲取此信息?
謝謝。
問題是之前的'includes'之一是對帖子作出了不同的查詢,因此分類查詢被清除。謝謝你所有,並要小心這個;-) – francadaval
https://codex.wordpress.org/Function_Reference/$post – 2017-02-24 13:29:45