2

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.

3

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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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