• 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)
  • 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#A_Page_of_Posts

    what posts (from what category or by what criteria) are you trying to show?

    Thread Starter devmitrovics

    (@devmitrovics)

    I want to show all posts from system not by category or anything else πŸ™‚

    Thread Starter devmitrovics

    (@devmitrovics)

    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

    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

    (@devmitrovics)

    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.