If you are looking for a way to separate your blog posts from the rest of your site, or if you would like to add an easy way to access all recent posts…. keep reading.
WordPress has a built-in feature that allows you to assign a Page as your Static Homepage and another Page as your Post Page. But this feature does not work well for all themes because it assumes that index.php (your homepage) contains your list of recent posts. Therefore, when you create a new Page called “Blog” and assign that as your Post Page…. what happens? The “Blog” page will look exactly like your homepage.
This method works great for themes that only have posts on the homepage. But if your theme contains other homepage elements such as Image Sliders, Highlights sections, etc. you may not want those elements appearing on your “Blog” page. This is when you will want to create a Page Template dedicated to displaying a list of your recent posts. Here’s how:
1) Open a new text file and add this to the very top of the file:
Template Name: Blog Template
2) Next, copy and paste the entire contents of your archive.php page into your new text file, directly below the code mentioned above. (Most themes contain an archive.php file which defines how the list of recent posts should be displayed. Different themes may call this file something else but in most cases, it is archive.php.)
3) Within the newly pasted code, search for the start of the loop: It begins with:
<?php if (have_posts()) : ?>
Directly ABOVE <?php if (have_posts()) : ?> paste your query parameters. For a list of all recent posts, you would paste:
<?php query_posts(‘showposts=10′); ?>
You can change the “10″ to the number of posts you want to show per page. You can also change this query to show posts from specific categories like:
<?php query_posts(‘cat=12,5′); ?>
4) Save this file as: template_blog.php and upload it to your theme folder.
5) Create a new page where you wish to display your posts and give it a name such as “Blog”, “Posts”, “Latest News” …etc. On the right side of the Page edit screen, select Blog Template from the Templates drop-down menu. Click Update to save.
Now your latest posts will display on this Page!