0

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(); ?>

1 Answer 1

1

The 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.

1
  • Thanks that works! I forgot that WordPress uses the homepage to display all posts.
    – Cypher
    Commented Feb 18, 2020 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.