Problem with conditional posts navigation
-
I’ve searched the forums and almost have this figured out, but there’s still a problem.
To prevent empty tags, I’m using a conditional statement to show or hide the navigation to older/newer posts. The code I’m using in my theme is:
<?php if (show_posts_nav()) : ?> <ul class="pagination"> <li class="prevlink"><?php next_posts_link('Older Posts'); ?></li> <li class="nextlink"><?php previous_posts_link('Newer Posts'); ?></li> </ul> <?php endif; ?>
and in my functions I have:
function show_posts_nav() { global $wp_query; return ($wp_query->max_num_pages > 1); }
If there’s no navigation necessary, there’s no ul. But if there’s only one link necessary, I still get an empty li tag.
Anyone know how to prevent that?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Problem with conditional posts navigation’ is closed to new replies.