Last active
April 27, 2018 05:28
-
-
Save nickdavis/862f79ca91be6a854243 to your computer and use it in GitHub Desktop.
Using default WordPress next / prev post links check if one exists first and update CSS classes accordingly [not complete code]
This file contains 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
<?php | |
// @link http://www.jaredatchison.com/code/add-next-previous-post-links-genesis/ | |
// Check if there are next or previous posts | |
// First paramter is 'in_same_term'?, make sure it matches third parameter in previous_post_link / next_post_link (which defaults to false) | |
$next = get_adjacent_post( false, '', false ); | |
$previous = get_adjacent_post( false, '', true ); | |
//Set up CSS styles to know if there are next or previous posts only | |
if ( ! $next ) { | |
echo '<ul class="article_navigation previous-only">'; | |
} | |
else if ( ! $previous ) { | |
echo '<ul class="article_navigation next-only">'; | |
} | |
else { | |
echo '<ul class="article_navigation">'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment