How do I get blog posts to appear within CMS?

I’m working with a WordPress CMS website that was set up without a blog. I want the site to continue to function as it has, with mostly static pages, including the home page. I want a page called “Blog” to function as a blog.

Now I’ve been asked to add a blog, and what I expected would be extremely easy isn’t turning out that way.

Read More

This is what I’ve tried:

  1. Added a page called “Blog” and published it.
  2. Under Settings >> Reading, set the Posts
    page to Blog. (A Static Page is selected, with Front Page set to
    “Home”.)
  3. Added Blog to the main navigation in the Theme Options.
  4. Created 2 posts.

When I view the Blog page, two messages appear instead of the two blog posts:

Please go to Admin Panel > Settings > Reading and setup "Front page displays" option

Another detail that may be relevant is there are only 2 page templates: Default Template and Archives. If I select Archives as the template for Blog, I get an archive menu that links to the 2 posts I set up.

Should I have a Blog Template as well? How can I add one? What else should I look at?

Related posts

Leave a Reply

2 comments

  1. So, everything seems to be set up correctly. The setting in your step 2 is everything that needs to be done. I won’t be able to help you without seeing how the theme’s template files are structured.

    The way it usually works when you apply the setting in your step 2 is that WordPress looks for a template called front-page.php, if it doesn’t exist then WordPress uses index.php.

    Now, one of these templates must use the regular post loop, that is

    if ( have_posts() ) :
    while ( have_posts() ) :
    the_post()

    I assume that this loop is not present in your index.php or front-page.php files, and this is why your posts are not showing.

  2. Pogoking’s answer helped point me in the right direction, but didn’t solve the problem. This is what I ended up doing.

    I created a new template within the customized theme we are using and edited the blog page to use the new template.

    .../html/wp-content/themes/[custom theme name]/blogposts.php
    

    I added the loop to the new template along with a query with a few parameters. I’m sure I’ll modify the template substantially, but it works for now. All blog posts are displayed as I want them to.

    Here is my code:

    <?php
    /*
    Template Name: Blog Template
    */
    ?>
    <?php get_header(); ?>
    
        <?php  
        $args = array(
                       'post_type' => 'post',
                       'posts_per_page' => 10,
                       'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                       );
    
        query_posts($args);  
        if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>  
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
        <h2><a href="<?php the_permalink(); ?>"
            title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
         </h2>
        <small>By <?php the_author_posts_link() ?>  | Published: <?php the_date() ?></small>
        <div class="thecontent">
        <br />
        <?php the_content(); ?>
        </div>
        <br />
        <hr>
        <br />
        <?php endwhile; else: ?>  
        // Our Blog will be online soon. Stay tuned... //
        <?php endif; ?> 
        <div class="navigation">
          <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
          <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
        </div>
        <?php
    wp_reset_query();  // Restore global post data
    ?>
        <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>