Grow your CSS skills. Land your dream job.

Previous post links

  • # July 27, 2010 at 9:50 pm

    Hi All,

    I have a page on a WP site I am doing that contains all posts form the "Blog" Category, but I don’t know how to get the previous post link at the bottom of the post.

    I am using this code to display the posts from the category:

    Code:
    < ?php $recent = new WP_Query(); ?>
    < ?php $recent->query(‘cat=3&showposts=4′); ?>
    < ?php while($recent->have_posts()) : $recent->the_post(); ?>

    ” rel=”bookmark”>< ?php the_title(); ?>

    < ?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
    < ?php the_content(); ?>
    < ?php endwhile; ?>
    < ?php posts_nav_link(); ?>

    You can find the page at http://nimbuswater.com/wordpress/whats-new/

    Thanks for your help!

    # August 3, 2010 at 3:02 pm

    Add this below your code:

    Code:
    < ?php if ( $wp_query->max_num_pages > 1 ) : ?>


    < ?php endif; ?>

    # August 8, 2010 at 2:30 pm

    Doesn’t look like this did anything.

    # August 8, 2010 at 9:17 pm

    If you’re on a single post, as in single.php, try this:

    Code:
    <?php next_post_link(‘<li class="prev-icn">%link</li>’); ?>
    <?php previous_post_link(‘<li class="next-icn">%link</li>’); ?>

    If you’re on an archive page, a listing of posts, try this:

    Code:
    <?php next_posts_link(‘<span class="prev-icn">Next</span>’); ?>
    <?php previous_posts_link(‘<span class="next-icn">Previous</span>’); ?>

    You can obviously change the argument here to get different results. I’d check the codex for what you can pass to these things.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".