我很难让get_template_part()在我的index.php页面上工作。模板部分在循环中,并引用“标准”post格式。
<section id="content" class="site-content blog-page">
<div class="container">
<?php if ( is_home() || ( is_front_page() && is_home() ) ) : ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'template-parts/post/content', get_post_format() ); ?>
<?php get_template_part( 'template-parts/navigation/navigation', 'pagination' ); ?>
<?php endwhile; ?>
<?php else : ?>
<p><?php _e( 'Sorry, no postes matched your criteria' ); ?></p>
<?php endif; ?>
<?php endif; ?>
</div><!-- Ends .container -->
<?php get_footer(); ?>网址:http://magneton.carbonium.no/
编辑更改了index.php代码以反映@rudtek示例。模板部件仍未加载。
发布于 2017-04-28 19:14:04
想想我的评论.说:
<section id="content" class="site-content blog-page">
<div class="container">
<?php if ( is_home() || ( is_front_page() && is_home() ) ) : ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2> There are posts but template parts aren't found </h2>
<?php get_template_part( 'template-parts/post/content', get_post_format() ); ?>
<?php get_template_part( 'template-parts/navigation/navigation', 'pagination' ); ?>
<?php endwhile; ?>
<?php else : ?>
<h2> There are no posts.</h2>
<?php endif; ?>
<?php else : ?>
<h2> THIS IS not home or front </h2>
<?php endif; ?>
</div><!-- Ends .container --> 试试这个,所以现在我们知道它是不在家还是没有帖子,或者它找不到你的模板。
https://wordpress.stackexchange.com/questions/265283
复制相似问题