WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Paged Post (2 posts)

  1. MaddTechWF
    Member
    Posted 4 years ago #

    How would I go about creating a page that shows the last 5 posts and then has a next/previous buttons?

  2. kz
    Member
    Posted 4 years ago #

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('page_per_posts=5&paged=' . $paged);
      if(have_posts()) :
        while(have_posts()) :
          the_post();
          ?>
          <a href="<? the_permalink(); ?>"><?php the_title() ?></a>
          <div class="entry"><?php the_content(); ?></div>
          <?php
        endwhile;
        ?>
        <div class="navigation">
          <div class="alignleft"><?php previous_posts_link('&laquo; Newer') ?></div>
          <div class="alignright"><?php next_posts_link('Older &raquo;') ?></div>
        </div>
        <?php
      endif;
    wp_reset_query();
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.