My blog page is showing only the very first published page, and not the subsequent posts. I’ve noticed, too, that when viewing the page source, the blog page seems to be using single.php instead of index.php which is what I’ve set the template to be. Could this be the issue?
Below is the code in question:
index.php
<?php
/*
Template Name: Blog
*/
?>
<?php get_header(); ?>
<div id="container">
<div id="blog">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div id="headline">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div><!-- end headline -->
<div id="post-meta">
<p>written by <?php the_author(); ?> on <?php the_date(); ?></p>
</div><!-- end post-meta -->
<div id="post">
<?php the_content('read more...'); ?>
</div><!-- end post -->
<?php endwhile; ?>
<?php else : ?>
<p>I'm not sure what you're looking for.</p>
<?php endif; ?>
</div><!-- end blog -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
It appears that
blog.php
is a custom static page template, yes?If so, then the primary loop will display the post content of the static page to which it is applied.
If you want to create a custom page template that displays blog posts, you will need to create a secondary loop to query/output the required blog posts. I would say to follow the example in the Codex, but in this case: don’t. That example currently uses
query_posts()
, which is an incorrect implementation.However: I suspect that what you’re really trying to do here is to customize your blog posts index? If so, you shouldn’t be using a custom page template at all, but rather, should be creating/modifying the appropriate template file, which, for the blog posts index, is (in order of priority):
home.php
index.php
You may want to delete sections of the php template that’s not working to fix this. I discovered the template I copied from a blog as a starter template had errors in it from the start. Thus why the feed wasn’t working.
Please verify that in Settings -> reading the number of posts -> Blog pages show at most the value is greater than 1.