Title: WordPress post loop and page template
Last modified: August 21, 2016

---

# WordPress post loop and page template

 *  [devmitrovics](https://wordpress.org/support/users/devmitrovics/)
 * (@devmitrovics)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/wordpress-post-loop-and-page-template/)
 * i am strugling with huge problem 🙁 Whole day i am trying loop to work. I use
   default wordpress theme. if i put loop on index.php or home.php posts are working
   fine. And if i put loop in some pate templte for example blog-template.php i 
   get blank screen ?? How loop work on index.php or archive.php or categories.php
   but not on any page templates???
 *     ```
       <?php if ( have_posts() ) : ?>
   
               <?php /* The loop */ ?>
               <?php while ( have_posts() ) : the_post(); ?>
                   <?php get_template_part( 'content', get_post_format() ); ?>
               <?php endwhile; ?>
   
               <?php twentythirteen_paging_nav(); ?>
   
           <?php else : ?>
               <?php get_template_part( 'content', 'none' ); ?>
           <?php endif; ?>
       ```
   
 * As i said with this code on index.php i get graet results along with prev/next
   page buttons. But if i use on template file i got blank screen? Please help

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/wordpress-post-loop-and-page-template/#post-4296177)
 * in a page template, you need to use a query to tell the loop what posts to show;
 * [http://codex.wordpress.org/Page_Templates](http://codex.wordpress.org/Page_Templates)
 * [http://codex.wordpress.org/Page_Templates#A_Page_of_Posts](http://codex.wordpress.org/Page_Templates#A_Page_of_Posts)
 * what posts (from what category or by what criteria) are you trying to show?
 *  Thread Starter [devmitrovics](https://wordpress.org/support/users/devmitrovics/)
 * (@devmitrovics)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/wordpress-post-loop-and-page-template/#post-4296180)
 * I want to show all posts from system not by category or anything else 🙂
 *  Thread Starter [devmitrovics](https://wordpress.org/support/users/devmitrovics/)
 * (@devmitrovics)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/wordpress-post-loop-and-page-template/#post-4296198)
 * In basic i need two things on whole world but it seems there isnt solution.
    
   I need all posts listed on one page with pagination or those older/newer posts
   links thats all i need
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/wordpress-post-loop-and-page-template/#post-4296233)
 * > I need all posts listed on one page with pagination or those older/newer posts
   > links thats all i need
 * try:
 *     ```
       <?php
       $args = array(
         'posts_per_page' => 10,
         'paged' => get_query_var('paged')
       );
       query_posts( $args );
       if ( have_posts() ) : ?>
   
               <?php /* The loop */ ?>
               <?php while ( have_posts() ) : the_post(); ?>
                   <?php get_template_part( 'content', get_post_format() ); ?>
               <?php endwhile; ?>
   
               <?php twentythirteen_paging_nav(); ?>
   
           <?php else : ?>
               <?php get_template_part( 'content', 'none' ); ?>
           <?php endif; ?>
       ```
   
 *  Thread Starter [devmitrovics](https://wordpress.org/support/users/devmitrovics/)
 * (@devmitrovics)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/wordpress-post-loop-and-page-template/#post-4296238)
 * You are KING! i lost whole day on forums trying to solve this.
 * Thank you MASTER! :)))

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘WordPress post loop and page template’ is closed to new replies.

 * 5 replies
 * 2 participants
 * Last reply from: [devmitrovics](https://wordpress.org/support/users/devmitrovics/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/wordpress-post-loop-and-page-template/#post-4296238)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
