How To Add Blog Posts To A Wordpress Page

By default pages in Wordpress websites will not display blog posts. However, there is a quick an easy way to edit the code of your theme page to handle this.

1. Wordpress Theme Page Code

First create a new page for your theme. Then add the following code to the web page in the area where you normally display the main content:

<?php
global $more;
$more = 0;

  $post_per_page = 10; // -1 shows all posts
  $args=array('category_name' => 'Latest News', 'posts_per_page' => $post_per_page);
?>

<?php query_posts($args); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

        <div class="post" id="post-<?php the_ID(); ?>">
            <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
            <?php the_content('read more ...'); ?>
        </div>

    <?php endwhile; ?>
<?php endif; ?>

The above code allows you to select posts from a specific categories and display the excerpts on the page. In this example we select our “Latest News” category – change the ‘category_name’ => ‘Latest News’ to suit your requirements.

You can also control the number of posts displayed by changing the “$post_per_page” parameter.

2. How To Use In Your Page

Very simply – upload your new template file to your themes folder, create a new page in your Wordpress admin and assign the new template file to this page.

There you have it – a custom page on your Wordpress website showing latest posts. To add more pages just repeat the process by creating a new theme page file and change category name parameter.

2 Responses to “How To Add Blog Posts To A Wordpress Page”

  1. M Spy says:

    what do you mean “By default pages in Wordpress websites will not display blog posts”..? Isn’t that what WP is mostly about??

  2. admin says:

    The tutorial refers to a “Wordpress page”, which has a specific meaning. Pages in Wordpress are for non-blog post content that usually isn’t time-dependent – examples of pages you could add to your website are – about us, company profile, contact details, etc. These are created using the “Page” options in the Wordpress admin menu.

    Pages would generally be accessed via your main navigation or sub-navigation

Leave a Reply