Support » Themes and Templates » Styling next_ and previous_posts_link

  • Hey everyone,

    I’m working on a new theme for my blog, and I’ve done most of the CSS except for previous_posts_link() and next_posts_link(). Each one is in a separate div, and the style is fine, except that when the link isn’t there, ie when you’re at the first or last page, the div still shows up. I’d like to be able to hide the div for the links that aren’t there, because the divs have backgrounds and borders. Is there a piece of code I can add to hide the empty divs?

    My current setup looks like:

    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
    	<div id="nav-above" class="navigation">
    		<div class="nav-previous-above"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'capsules' ) ); ?></div>
    		<div class="nav-next-above"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'capsules' ) ); ?></div>
    	</div><!-- #nav-above -->
    <?php endif; ?>

    above and below the loop.

    Thanks in advance!

  • The topic ‘Styling next_ and previous_posts_link’ is closed to new replies.