我创建了一个自定义页面,显示所有带有模板的帖子:
<?php
/*
Template Name: All posts
*/
get_header();
?>
</header>
<div role="main" id="content" class="content-warp">
<div class="container">
<div id="primary" class="content-area col-md-8 post-list">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<div class="entry">
<?php the_content(); ?>
<?php
$current_date = "";
$count_posts = wp_count_posts();
$nextpost = 0;
$published_posts = $count_posts->publish;
$myposts = get_posts(array('posts_per_page' => $published_posts));
foreach ($myposts as $post) :
get_template_part('content', 'content-single');
?>
<?php endforeach; ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_sidebar('page'); ?>
<div style="clear:both"></div>
</div>
</div>
<?php get_footer(); ?>
但它不显示 Posts 的 post_content (所有剩余数据都正常)。
顺便说一句,使用默认 UI 类别 (content.php),我只需调用下面的代码,一切正常:具有新模板但具有 post_content 的相同 UI)。
<?php get_template_part( 'content', 'single' ); ?>
我不知道为什么 post_content 在我的新模板中为空。我正在使用 Llorix One LiteVersion:0.1.7
任何帮助,谢谢。