2 Ways of Creating Separate Blog Pages in WordPress
I. Using index.php as a blog template
This method is very simple. It is default functionality in WordPress, with no additional code. It is used on many websites.
You should know one thing: some themes doesn’t have code for blogs in their index.php file, for such themes this method doesn’t work. In that case I recommend you to look at the second method, you can also find it in this post.
Step 1. Creating a Blog Page
First, go to the Pages > Add new, after that fill the title input field, I suppose it will be «Blog», and save the page.
Step 2. Customizing Locations for Homepage and Blog Posts
Go to the Settings > Reading and set up a static page as the homepage and our blog page as a posts page.
Step 3. Add a Menu Item
This is an unnecessary step. If you have finished the second step, the blog will appears on the page URL, you just created. The blog page will also use
index.php file as the template.
Anyway, if your current theme supports menus, you can add this page to website menus. If you want to do this, go to Appearance > Menus, add blog page to any menu and save it.
II. Using Your Own Page Template for Blog Posts
This method allows you to create blog sections using your own page template. This way is good when you need to display posts with your own parameters. You can also create multiple blog sections with different query arguments.
So, let’s begin.
Step 1. Creating Page Template
I suppose you already know how to do this, if you don’t, then open your current theme folder and create a php file there. You can name it as your want, e.g.
blog-template.php. Into this file add the following code:
<?php /* * Template name: Blog section template */
Step 2. Creating a Page
This step is similar to the first step in the first method, the only difference is that you should specify a page template in the «Page Attributes» section.
Step 3. Paging Navigation
Of course, we need a pagination for our blog section. You probably use some sort of plugins or your own function for these purposes. If something goes wrong, I recommend you to use WP-PageNavi plugin. I made some tests – this plugin works fine with the code from this tutorial.
Step 4. The Code for Page Template
This is just an example without some of important template functions such as
get_footer(). But this template contains everything you need to test your blog page.
<?php /* * Template name: Blog section template */ $current_page = (get_query_var('paged')) ? get_query_var('paged') : 1; // get current page number $args = array( 'posts_per_page' => get_option('posts_per_page'), // the value from Settings > Reading by default 'paged' => $current_page // current page ); query_posts( $args ); $wp_query->is_archive = true; $wp_query->is_home = false; while(have_posts()): the_post(); ?> <h2><?php the_title() /* post title */ ?></h2> <p><?php the_content() /* post content */ ?></p> <?php endwhile; if( function_exists('wp_pagenavi') ) wp_pagenavi(); // WP-PageNavi function
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
i am trying to use this tuterial but the page i have created in linking to home page …….
who to redirect it to blog-theme.php
Compared to other web languages that require a bit of study, PHP does not require one to spend a lot of time researching a manual. Thanks to the syntax being logical and command functions describing exactly what they do, one can easily get right to the part of creating and optimizingthe application.If you have programming experience in both Perl and C, then learning PHP will be quite easy, as its syntax is based on these languages.Since PHP is an open source web language, it’s completely free of cost.Depending on how you code, (http://cedarsoftware.co.uk )PHP can turn out to be an efficient web language to use. In fact, PHP is known to be scalable when writing code as well as in creating applications and is very reliable when you need to serve several web pages.If you get stuck or are getting started when using PHP, one of the best places you can find information about the language is php.net apart from php pros from numerous websites and forums that are available over the internet
Nice work, A small issue ;)
Is working only for index.php, (for the latest post)
I have create multiple blog pages which each one display only post by a specific category and is not working correctly !
any ideas ? :)
There are plenty of another pagenavi solutions — check them :) I can write a post about page navigation without plugins if you want as well (on Monday).
Thanks for your wonderful post!
Thank you! You helped me a lot!
Thank you for your post but I can’t see the template option in my page settings to setup it to Blog template. Do you know why?
What is your template file name and where did you create it?
I am trying to create a template from a static html template. I already have the homepage working but now I want to add blog, so I follow your instruction and it works until where I need to setup the page attribute for the blog page.
The option to setup the template doesn’t appear if I set this page as a Posts page, but if I remove this attribute I can setup the template. I can’t figure out what is happen.
Thank you for your help.
I see. When you set a page as a Posts page in Settings > Reading, it will use
index.phptemplate automatically! It is just how it works.
how create custom multiple bolg page in one wordpress templates.
I’ve looked about about a million blog posts about this, and they all say the same thing, and they all OVERLOOK the fact that most themes these days have their own (very nice looking) home page…which if you select “static page”, is overwritten!
So how do you KEEP the theme’s nicely designed home page, while at the same time creating a separate blog posts page?
Lots of people have this question (from forums and comments) but literally no article is addressing it.
Can you update this article to answer this question, and/or write a new article to help all of us? Thank you!!
Is your theme homepage coded as a Page Template?