Last active
December 14, 2015 10:49
-
-
Save scottlyttle/5075092 to your computer and use it in GitHub Desktop.
jQuery snippet to output a span in place of a next or previous link in WordPress (as one is not output when there is no next previous page).
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
| // store the links parent selectors as variables | |
| var $next = $(".next"); | |
| var $prev = $(".prev"); | |
| // if the prev posts link doesn't exist but the next link does | |
| if ($prev.children().length == 0 && $next.children().length > 0) { | |
| // add a span with prev | |
| $prev.append('<span class="disabled">Prev</span>'); | |
| // if the next posts link doesn't exist but the prev one does | |
| } else if ($next.children().length == 0 && $prev.children().length > 0) { | |
| // add a span with next | |
| $next.append('<span class="disabled">Next</span>'); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment