Navigate next, previous adjacent post with jquery and the left, right keys

If you are using adjacent post relational links in the head of your wordpress theme add this little bit of jquery. This will let people navigate next, previous adjacent post with the left and right arrow keys.

		if (e.which == 37) { // left arrow
		   if(!prev) return false;
			window.location.href = $('link[rel=prev]').attr('href');
		if (e.which == 39) { // right arrow
		   if(!next) return false;
			window.location.href = $('link[rel=next]').attr('href');

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!