Wordpress: Conditional page navigation


/ Published in: PHP
Save to your folder(s)

Only show page navigation when necessary (ie when there is more than on page of results)


Copy this code and paste it in your HTML
  1. <?php global $wp_query;
  2. if ($wp_query->max_num_pages > 1) { ?>
  3. <div class='navigation'>
  4. <span class='older'><?php next_posts_link('&laquo; Older Entries'); ?></span>
  5. <span class='newer'><?php previous_posts_link('Newer Entries &raquo;'); ?></span>
  6. </div>
  7. <?php } ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.