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.

Im trying to have 5 posts for page in my blog. This is what Ive used in index.php

<?php
    get_header();
    query_posts('posts_per_page=5');

    // The Loop
    if (have_posts()){

        while (have_posts()){

            //Iterate the cursor on the next post
            the_post();

            echo "<a class='more-link' href='";
            the_permalink();
            echo "'><h1>";
            the_title();
            echo "</h1></a>";

            echo "<div class='meta'>";
            the_date();
            echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
            comments_number();
            echo "</div>";

            echo "<a class='more-link' href='";
            the_permalink();
            echo "'>";
            the_post_thumbnail();
            echo "</a>";

            the_excerpt();
            echo "<a class='more-link' href='";
            the_permalink();
            echo "'>Continue reading</a>";

            echo "<hr>";
        }
    }

    get_footer();
?>

I want to put a link at the bottom for "show older posts", but I dont know how should I alter the file to do this. Any idea, please? Thank you

share|improve this question
    
Your loop ends at the file footer.php - can you paste that one too? –  Sagive SEO Apr 3 '12 at 19:37
    
There no additional PHP code, just closing tags </body></htm> –  Dbugger Apr 3 '12 at 19:45
add comment

1 Answer 1

up vote 1 down vote accepted

Ok then... try this (hope i got your request right):

REVISED

<?php
    get_header();
    query_posts( array(
          'posts_per_page' => 5,
          'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
     ));

    // The Loop
    if (have_posts()){

        while (have_posts()){

            //Iterate the cursor on the next post
            the_post();

            echo "<a class='more-link' href='";
            the_permalink();
            echo "'><h1>";
            the_title();
            echo "</h1></a>";

            echo "<div class='meta'>";
            the_date();
            echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
            comments_number();
            echo "</div>";

            echo "<a class='more-link' href='";
            the_permalink();
            echo "'>";
            the_post_thumbnail();
            echo "</a>";

            the_excerpt();
            echo "<a class='more-link' href='";
            the_permalink();
            echo "'>Continue reading</a>";

            echo "<hr>";
        }
    }
    ?>
    <div class="navigation">
      <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
      <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
    </div>
    <?php get_footer(); ?>

.

Hope this helps,
Cheers, Sagive.

share|improve this answer
    
Thats not what I mean. What I want is a link to the list of the NEXT 5 older posts. With that I will only see the 6th newest post. –  Dbugger Apr 3 '12 at 21:41
1  
Aplogies.. didnt see that query at the head of your loop, try it now.. –  Sagive SEO Apr 3 '12 at 22:08
    
Exactly what I wanted! I didnt know the "paged" option. Million thanks ;) –  Dbugger Apr 3 '12 at 22:18
    
My pleasure mate ;) –  Sagive SEO Apr 3 '12 at 23:05
add comment

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.