admin管理员组文章数量:1389772
UPDATE 1: I tried creating a new page and the header and footer is showing, but not the posts. UPDATE 2: If I update the Reading settings to Post page and select the page I created with the custom template, nothing is showing.
<?php /* Template Name: Blog Template */ ?>
<?php get_header(); ?>
<h1>Blog posts</h1>
<div class="container">
<?php while(have_posts()): the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
</div>
<?php get_footer(); ?>
UPDATE 1: I tried creating a new page and the header and footer is showing, but not the posts. UPDATE 2: If I update the Reading settings to Post page and select the page I created with the custom template, nothing is showing.
<?php /* Template Name: Blog Template */ ?>
<?php get_header(); ?>
<h1>Blog posts</h1>
<div class="container">
<?php while(have_posts()): the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
</div>
<?php get_footer(); ?>
Share
Improve this question
edited Feb 18, 2020 at 3:08
Cypher
asked Feb 18, 2020 at 2:54
CypherCypher
451 silver badge5 bronze badges
1 Answer
Reset to default 1The template for displaying all your posts should not be a custom page template. You should set the page you want to use as your Posts page in Settings > Reading. Then, as per the Template Hierarchy, your theme will automatically use home.php
for this page, or index.php
if that does not exist.
So you should save your template as home.php
, without the /* Template Name: Blog Template */
comment, and set the page you want to use for displaying posts in Settings > Reading.
本文标签: postsWhy is my custom template not showing anything
版权声明:本文标题:posts - Why is my custom template not showing anything? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744740254a2622565.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论