Skip to content

Instantly share code, notes, and snippets.

@alwerner
Last active December 20, 2015 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alwerner/6188060 to your computer and use it in GitHub Desktop.
Save alwerner/6188060 to your computer and use it in GitHub Desktop.
Conditional Wordpress pagination
// in functions.php, check to see if there's more than one page:
function show_posts_pag() {
global $wp_query;
return ($wp_query -> max_num_pages > 1);
}
// on page::
<?php if (show_posts_pag()) : ?>
<div class='pagination'>
<span class='older'><?php next_posts_link('&laquo; Older Entries'); ?></span>
<span class='newer'><?php previous_posts_link('Newer Entries &raquo;'); ?></span>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment