Last active
December 20, 2015 20:08
-
-
Save alwerner/6188060 to your computer and use it in GitHub Desktop.
Conditional Wordpress pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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('« Older Entries'); ?></span> | |
<span class='newer'><?php previous_posts_link('Newer Entries »'); ?></span> | |
</div> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment