WordPress page flip using a keyboard

Source: Internet
Author: User

 

If you can use the keyboard arrow keys to perform the up/down page flip operation, it will be very convenient and you will have nothing to worry about. You can use the keyboard to implement the WordPress page flip function. The implementation method is simple, and a piece of JS Code is done.

  1. // Flip the keyboard
  2. <? Php wp_reset_query (); if (is_home () | is_archive () | is_search () {?>
  3. <Script type = "text/javascript">
  4. Document. onkeydown = chang_page; function chang_page (e ){
  5. Var e = e | event,
  6. Keycode = e. which | e. keyCode;
  7. If (keycode = 33 | keycode = 37) location = '<? Php echo get_previus_posts_page_link ();?> ';
  8. If (keycode = 34 | keycode = 39) location = '<? Php echo get_next_posts_page_link ();?> ';
  9. }
  10. </Script>
  11. <? Php }?>
  12. <? Php wp_reset_query (); if (is_single () {?>
  13. <Script type = "text/javascript">
  14. Document. onkeydown = chang_page; function chang_page (e ){
  15. Var e = e | event,
  16. Keycode = e. which | e. keyCode;
  17. If (keycode = 33 | keycode = 37) location = '<? Php echo get_permalink (get_adjacent_post (false, '', false);?> ';
  18. If (keycode = 34 | keycode = 39) location = '<? Php echo get_permalink (get_adjacent_post (false, '', true);?> ';
  19. }
  20. </Script>
  21. <? Php }?>

Add the above JS Code to the header template header. php or footer template footer. php. Click the left and right direction keys on the keyboard and the Page UpPage Down to check whether it is convenient. You can flip the article list page and the next article in the body.

However, page turning on the text Keyboard will affect the use of the keyboard to move the cursor during message editing, so you can <? Php wp_reset_query (); if (is_single () {?> And the subsequent deletion, only use the keyboard to flip pages on the article list page.

In addition, some people have made a plug-in specifically to implement this function: Easy keyboard shortcut cut navigation. The above code is extracted and modified from it, probably because of the functionality that JavaScript code can implement, so few people use this plug-in, and the score is only zero.

From zmingcx.com

Related 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.