By default WordPress display your content in a blog format on the homepage. Users often modify for their needs by creating a custom home page in WordPress. What if you want to use WordPress to run your entire static site, and also use it as a blog? Well in this article, we will show you how to create a separate page for blog posts in WordPress.
There are few different methods you can use to create a separate page for blog posts. It all depends on which method you used to create the custom home page. If you created the homepage by creating a file called home.php, then you want to follow the method below:
1. First copy your index.php file and save it as blog.php.
2. Make it a Custom WordPress Page Template.
3. Create a new WordPress page in your WP-Admin panel. Title the page Blog, and before you hit publish, make sure you select the custom page template as shown in Step 2.
4. Publish the Page.
Next you need to edit blog.php file. Find the Loop, which should look something like this:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Replace this top part with the code below:
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('posts_per_page=5'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
The posts_per_page variable does exactly what it sounds like. It tells WordPress to display X amount of posts on each page. You may change the number from 5 to whatever you like.
Find a line that looks like this:
<?php else : ?>
Remove this code and any else code such as the 404 content etc. You should already have a 404.php file in place for that.
Next you need to find this code:
<?php endif; ?>
Replace it with:
<?php $wp_query = null; $wp_query = $temp;?>
Ladies and gentleman, you now have a separate page for blog posts. Depending on your permalink structure, you can link it in other sites such as twitter, facebook etc. You can also list it in your navigation bar with the WordPress 3.0 Custom Menus.
Method 2
If you want to use the built-in Static / Blog page method, then you can do so as well. This method is less code intensive, but it does not allow for customizations that some developers might want.
Create two new pages, one can be called “Welcome” or whatever you want to call your homepage. The next should be called “Blog” or whatever you want to call your blog page.
If you already have a file called home.php in your theme, then you will need to rename it to welcome.php and make it a Custom WordPress Page Template by adding the codes at the top. Then in your Welcome page, select the Welcome Template.
Go to Settings » Reading:

Choose the Static options and select your two pages.
Once you do this, you are good to go. If you have any questions, feel free to ask in the comments.








Love the simplicity of your tutorials! Doing a marvelous job, be blessed.
Hi all. This tutorial has been great – thank you for posting. I am somewhat new to WP and have followed the Option 2 part to install my blog and for some reason my home/landing page pops up with the blog page after following the steps. My site: http://www.landsharkanalytics.com/
Any ideas what I could be doing wrong?
I appreciate the guidance.
Regards,
Daniel
Thanks! I’m impressed with myself that it worked! Good tutorial, easy to follow if your eyes don’t glaze over when you start displaying code
Can you help me determine what am I doing wrong? I have followed all of the steps.
Thanks your the article, been scratching around for a solution to this for a few days. Is there any way to paginate the list using method 1 above? And also I want to use the tag to truncate the post, rather than ‘the excerpt’, is that possible?
Thanks again!
Hello Wpbeginner (great site by the way)… I’ve been struggling with this for the past few days: my problem: the theme I’m using is, by default, static. (I’m using Graphic by Dessign) Therefore, the loop is not present in the index (I’ve nothing named “home.php.”) How might I go about using a page, accessible via the sidebar on my homepage, as my blog?
Merci bien!
The loop might be in the loop.php file or something similarly named.
That file doesn’t exist either. Could I create one manually? Or would that throw a stick in this theme’s spoke?
If none of those exist, then you might be running a child theme. You would have to understand how the child theme works each have different hooks and such to make this work.
Hi
I know this is an old post however it is as good a place to start.
I am using a basic theme and have setup a separate page called blog as described in method 1.
All works as it should, the theme styles everything fine.
My question is how can I filter the feed so it only shows posts from a certain category id.
The most simple way is to add the category to the menu, however I would like to keep the page name in the url rather than website.com/category/blog/title.
Any help much appreciated.
Richard
You would have to use wp_query and modify the loop like it is shown in this post:
http://www.wpbeginner.com/wp-tutorials/how-to-display-recent-posts-from-a-specific-category-in-wordpress/
Hope that helps.
Hi,
Thanks for the super fast response.
A bit of juggling and works great.
Many thanks
Richard
so much thanks for this great tip …….
Just wanted to say thanks for the article. Saved me a lot of time fiddling around as I’m not great with PHP
I used the first method but now the “Read more” link won’t appear after every blog post, it shows the full post even when I’m using the quicktag. How can I solve this?
This could be an issue with your theme.
I’m using Twenty Ten theme, and it works fine in the home page, but in the blog template I created it does not, even when I’m using the same code:
the_content( __( ‘Continue reading →’, ‘twentyten’ ) );
Not sure why it is not working for you. Would have to see what you are doing with the blog template. Can you send us an email using our contact mentioning this comment. We’d try our best to help.
Hey aldo! i know this post is old, but if u still haven’t found a solution, just replace:
“$wp_query->the_post()”
with
“$wp_query->the_excerpt()”
that solved it for me.
Hello, I was hoping this would work for me but so wordpress doesn’t seem to be recognizing my blog.php template…I have selected that template for the blog page and made the changes you mentioned. Can you let me know what I’m doing wrong? http://rootwholebody.com/blog
@ClareBean It seems that your blog page doesn’t have the codes to display anything.
YES! THANK YOU!!
Can someone answer this question posted below by another user? This is a need for me as well.
Thanks for the great article but heres my question!
What if I not only want to have 1 blog space seperated from home page, but 2, or 3?
How do I go about seperating content so that when I click each seperate blog in the nav bar, different content comes up instead of having the same content plastered allover pages of the same layout.
Please let me know if you have any tips
-Chris
That can be done by categories. I think you are confusing the idea mentioned in the posts with categories. The post is showing you how to have your normal blog and have a custom home page for your site (by default, blog page is the homepage).
@Anecia Finch You would simply use categories…. You do not have to create a BLOG page. You can simply have bunch of category pages.
Thx guys!!! Totally awesome of you guys to share this tutorial! It works great! Keep up the good work
the article was very informative i am a student and i find this useful for my projects thanks again
Hi WPBeginner. This was and is exactly what I have been looking for. I think I have got it set up for the most part, but could you please tell me how I would go about only pulling certain posts to be put into my custom blog page and them also not showing up in my default blog?
I also am not sure how to style my custom blog posts in my custom page. If I style one with css it affects the other one. I hope that makes sense. I basically need two separate blog pages and them to be styled completely different and one only pulling from certain posts.
I read in the comments that I can accomplish this by pulling from a category, but I don’t know exactly which function to use or where to place it. Any help would be so appreciate, AND THANKS AGAIN FOR A GREAT ARTICLE.
Thanks SO much! This solved my issue. I couldn’t understand how simply creating a blank Page and then naming it Blog (and then referring to it in the Setting-Reading panel) could work. But it did! Thank you so very much.
Can someone help me create a blog page for my site? I don’t want to mess anything up. My site is http://www.ontimedeals.com/
@jeckt84 We can do it for you for a fee if you don’t want to deal with codes.
I’ve achieved my static home page and secondary blog page. However, my blog page is not allowing for comments? Using the Readings setting sets up comments for all pages except this one, the only one where I would like it. Any help here? Thanks?
many thanks to this tutorial, now i have solved my problems..
Thanks much for the help! Like most stuff, I was “one click” away, but wasted 30 minutes trying to find it.
Thanks for showing the answer!
Jason
Thanks for the great article but heres my question!
What if I not only want to have 1 blog space seperated from home page, but 2, or 3?
How do I go about seperating content so that when I click each seperate blog in the nav bar, different content comes up instead of having the same content plastered allover pages of the same layout.
Please let me know if you have any tips
-Chris
@dorksgetlaid2 You need to use Method 2 mentioned above in the tutorial for what you are trying to accomplish.
Alright, here’s what I’m running into:
I’m looking to add a static page to my homepage and a blog page as well.
So, to create my static template page I just copied the page.php code verbatim (and added the theme language at the top), and named the file home.php (mostly because I was lazy and I wanted everything to look identical, I think this is where I went wrong). Everything was recognized properly so I created the added the new page exactly the way I wanted to. But, then when I go to load my home page it just gives me code, nothing else. Something isn’t loading properly. Is there somewhere I can go to get a generic wordpress page to use here? I think the page.php code is screwing me up.
The reason I made the home.php file for the static homepage was because it tells me to do so above. My main priority in all of this is getting the blog on my page to get new content. So do I even need to create the static home.php page to get a separate blog? Because technically my home page is the blog page with a few lines of code snipped out to make it look less like a blog post. And I’m ok with that.
http://www.stevengracelaw.com
Thanks!!! I’m almost there.
You. ROCK.
I’m creating my own WordPress theme, and this was EXACTLY what I needed. Now, to find out how to display only the excerpt up until the “read more” bit for each post with that code…
@giorgia1985 Our tutorials do not work with WordPress.com sites. These are only for self-hosted WordPress installs.
Hi I follow all these points. However, I am not able to post any featured image or image gallery on my blog page . This is is my blog http://whatsonthecatwalk.wordpress.com/
Can you please help me with that?
Thanks
Giorgia
Hi. Everything seems to be working great.
However, I have been trying to use <?php next_posts_link(); ?> and the previous post links for pagination. However, the previous and next links are not showing/displaying.
I read on another blog that if this happens, put a parameter for the number of pages. However, when I do this the links do show and seem to work, but the pagination continues according to the paramenter even if there are no blog entries for those pages (just shows a blank page).
Any ideas how to get this to work?
Thanks.
That did it for me! Thanks. What does that last bit do?
<?php $wp_query = null; $wp_query = $temp;?>
Thanks
What I am looking to do is similar. I am looking to have a static page as well as the blog appear on the main page of my wordpress site. Right now going to the settings section will only allow me to do one or the other. any feedback would be appreciated.
This would be done through custom coding the home.php file. You can pull in custom content as well as pulling in the most recent posts via the loop.
Some themes support this out of the box (i.e. under Appearance/Theme Settings).
For example the Atahualpa theme from http://bytesforall.com
We have this exact setup (static home page plus blog) at http://thewebalyst.com which is implemented using Atahualpa without any custom coding.
Mark (in London)
theWebalyst.com
Yes you are correct. Many frameworks and good themes come with a blog template such as Genesis and others.
Hi good post but not quite what I am looking for. Can you have a blog nav button at the top that appears only on the blog pages but not on any other pages on your site?
You can use the conditional tags like is_page.
I’m assuming the original poster wanted a second blog page to add posts. I have a site where all my blog posts get displayed on the home page. I want to create 2 to 3 seperate pages where I can enter unique blog posts relavant to those pages. My site has the home page and bio page. I want visitors to click on 3 more headings to view my blog posts for each heading. Does the above methods help me or am I a different situation?
The fastest way is to select all those posts, and add a unique tag to them. Then you can utilize query_post variable on a specific page template and pull posts with that tag. For less code savvy users, manually creating a list is the only option. But hopefully the internal linking feature will make that job easy
Hi,
I use your trick and got solution, Thanks a lot
one thing that i would like to say is in my site i used page name “Repair blog” and i created “repair-blog.php” but it doesn’t work. and finally i rename it with “page-repair-blog.php” and it’s works.
Again thank you for sharing such a precious information.
Very useful stuff, Just what I was looking for.
Thanks for posting this up.
Missing endwhile; on code. This is what is causing the page to go white screen or throw the errror “unexpected $end”
You have to add the More Break in the loop if you want it to work.
Thank you so much for this tut! Just what I was looking for, but couldn’t explain well enough to Google.
Thank you for this piece of code. You saved me so much time. I spent last 3 Days trying to figure out how to do that. I have one question, when i used your code it shows full post instead of like 5 lines and then link “more”. How i can fix it? Thank you.
You have to change the_content(); to the_excerpt();
This is a great tutorial. This will work nicely with the framework i’m building. Thank you for posting this.
I tried replacing the but it doesn’t exist in my file. I found this however: . And there are two these: . Regardless I made my best effort to change the page but got this error: Parse error: syntax error, unexpected $end in… which is the very last line of code (get_footer).
We cannot see your codes in the comments. Please email us the question if you can.
This white screens my page. I have no code on the template at all besides get_header() and get_footer()… when I add the code you’ve suggested, the page breaks. Any differences in this code with WordPress 3? Do you have any ideas as to why this would break my page?
The code should work with WP 3.0.
Thanks a lot! I am new to WP and was having trouble displaying posts on a page.
Hi There, a great tip and very useful, could you tell me how you would add new posts to the new blog page rather than the first 5 of your main blog?
This trick is to be used for those who are using WordPress as a CMS and have a custom homepage. Don’t understand your question clearly, so if you can explain a little bit more we would love to help.
I run a site called lovetextures.com where I add new posts every Monday, these are then placed on my homepage along with my other posts. What I am looking to do is add a blog to my site where I would like to keep my blog posts separate to my homepage posts.
Hope this clears it up a bit
From what it seems like that you do not want to display the monday posts in your blog. We assume that you are posting those in a specific category. You can use the query_posts function to exclude a specific category from a loop.
Nice post! I wasn’t aware of the first method, only the second. So thanks for showing me a new way of doing it.
Me too. Your timing is amazing, thanks very much.
Can you explain a little more about the pro’s and cons? I like the idea of using the built in mechanism but would like to know what the benefits of the first method are as I usually end up wanting to push things past the limit!
Mark
For developers, the first method is preferred because it gives you more control.
Mmm ok, you already said that in the article.
So my question remains unanswered.
Mark in th
@theWebalyst: for example, using the first method, you can edit the query to only pull blog posts from a specific category, or with a specific tag, etc.
I see, so somehow, following the built in feature removes the ability to customise some features? Or makes it more difficult?
Seems odd, but then I’m new to WordPress.
Thanks
Mark
Personally I use the second method. My portfolio site is built entirely on WordPress, custom page templates etc. I don’t feel I’ve lost any control whatsoever by not using the first method.
Oh man! I was looking for a solution to that problem! Thanks, WP Beginner!