Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Live site.

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(); ?>
share|improve this question
    
I'm not sure, but I think index.php should not be used a Template... and surely you've checked /wp-admin/options-reading.php, right? –  brasofilo May 24 '12 at 16:48

1 Answer 1

up vote 1 down vote accepted

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
share|improve this answer
    
Perfect, thank you again for your (continued) help. I definitely appreciate it. –  user1255049 May 24 '12 at 17:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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