Skip to content

Instantly share code, notes, and snippets.

@scottlyttle
Last active December 14, 2015 10:49
Show Gist options
  • Save scottlyttle/5075092 to your computer and use it in GitHub Desktop.
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).
// 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