Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a wordpress site with static page as the front page. I want to have /blog to display the recent posts. How can I do that?

thanks.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Create a page with a custom page template, then create a custom WP_Query object to return your last posts.

You can get something like:

<?php
/*
Template Name: Blog Page
*/
get_header();

$args = array(
    'post_type' => 'any', #all post types
    'posts_per_page' => 10 #get 10 posts
);
$query = new WP_Query( $args );
if($query->have_posts()):
  while($query->have_posts()):
    $query->the_post();
    the_title(); #display the title
  endwhile;
endif;

get_footer();
share|improve this answer
    
No need to wp_reset_postdata(), as it's a custom WP_Query object. –  kaiser Jan 20 '13 at 13:21
1  
Thanks Kaiser. Correcting the answer. –  RRikesh Jan 21 '13 at 4:42
    
i will try this one. How about the paging? –  JR Galia Jan 23 '13 at 13:19
    
These two questions will help you: wordpress.stackexchange.com/questions/31298/… and wordpress.stackexchange.com/questions/47259/… –  RRikesh Jan 23 '13 at 14:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.