1

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

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

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.

0

Please verify that in Settings -> reading the number of posts -> Blog pages show at most the value is greater than 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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