WordPress use keyboard left and RIGHT arrow keys to view the previous and next article

Source: Internet
Author: User

Through the keyboard to see the next article is not very convenient, this is actually a keyboard corresponding to the ASCII code to achieve, such as the right and left arrow keys corresponding to the ASCII code is 37 and 39, the following to see how to achieve this function:
1. Load the Jqury library, of course, many of the themes themselves have been loaded, if not add one on their own, many ways on the web, I will no longer say.
2. Add the following code to the footer.php before you can

1 <script>$(document).keydown(function(e){ if(e.keyCode==37){ var rnt = $(‘a[rel="next"]‘); if (rnt.length > 0){ location.href = rnt.attr(‘href‘); }; }; if(e.keyCode==39){ var rpv = $(‘a[rel="prev"]‘); if (rpv.length > 0){ location.href = rpv.attr(‘href‘); }; };});</script>

Below you can use the keyboard on the left and right keys to achieve the article to view the next page, very convenient.
PS: Note that some websites may have an impact on this feature if they use some cache plugins.

WordPress use keyboard left and RIGHT arrow keys to view the previous and next article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.