WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to show previous/next links when listing post titles? (3 posts)

  1. MD84
    Member
    Posted 4 years ago #

    Hey,

    I am showing 15 post titles in a list, but I do have more post titles. I want to use previous and next links to show the next list of post titles. How to do this?

    Script below is for listing post titles without the previous and next links:

    <?php query_posts('category_name=film&showposts=15'); ?>
    <ul style="list-style:none;">
    <?php while(have_posts()) : the_post(); ?>
    <li>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    </li>
    <?php endwhile; ?>
    <p><?php posts_nav_link(); ?></p>
    </ul>
  2. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

  3. MD84
    Member
    Posted 4 years ago #

    This worked for me!

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=film&posts_per_page=15&paged=$paged"); ?>
    <ul style="list-style:none;">
    <?php while(have_posts()) : the_post(); ?>
    <li>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    </li>
    <?php endwhile; ?>
    <p><?php wp_pagenavi(); ?></p>
    </ul>

    I used a plugin to alter the appearance of my page nav. You can also use:

    <?php posts_nav_link(); ?> instead of <?php wp_pagenavi(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic