Categories
Uncategorized

WordPress: How to display all posts in one page

Although displaying all your latest posts in Wordpress may seem like a no-brainer (after all, the default home page already displays your “Latest Posts”), doing so is kind of tricky if you are trying to do it in on a custom page.

Here’s a little code that can help you accomplish that.

Although displaying all your latest posts in WordPress may seem like a no-brainer (after all, the default home page already displays your  “Latest Posts”), doing so is kind of tricky if you are trying to do it in on a custom page.

Here’s a little code that can help you accomplish that. Basically, you need to override the $wp_query object with a new query:

<?php 
$wp_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish',
'posts_per_page'=>10, 'paged'=>get_query_var('paged')));
?>

Put this code at the beginning of your default  page.php template (or your custom page template) right before the Loop, and you are done!

Leave a Reply

Your email address will not be published. Required fields are marked *