Separate WP Blog Post

July 16, 2013 by Admin

How to Create a Separate Page for Blog Posts in WordPress?

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, now in this post I will tell you what changes you need in your code for a separate blog page. Supposing you created a new page from your index.php for blog and save it as blog.php, now you need to find the code below:

Find:  < ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Replace with:  
< ?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
while ($wp_query->have_posts()) : $wp_query->the_post();
then remove: 
< ?php else : ?>
< ?php endif; ?>
replace with: 
< ?php $wp_query = null; $wp_query = $temp;?>

‘posts_per_page=5′  is the number of posts that will be shown in the blog page.

Pin It

Latest comments

Listen, discuss, create. We make your website as unique as you.

Heliastar is a full-service design and development website dedicated to consistently providing high customer satisfaction by rendering excellent service, quality products, and furnishing an enjoyable atmosphere at an acceptable price/value relationship.

You can be assured that our friendly approach to web design and hosting does not mean that you have to compromise on price or quality.

Contact Us

Around the block ..

Phone +1 813 964 74 75

Email info{@}

Why Us?

• Highly Experienced in Web Design

• Experts in Web Development

• Experts in Server Administration

• 24/7 Email & Phone Support

• Cost-effective Approach

• Customer Support Plans

• High quality Servers (Linux & Windows)

• Free Consultation

• Free Staff Training

Recent Bolg Posts Recent CommentsCategories
Tag Cloud

© 2006 - 2017 Heliastar Design & Development , All Rights Reserved.