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.
- // Flip the keyboard
- <? Php wp_reset_query (); if (is_home () | is_archive () | is_search () {?>
- <Script type = "text/javascript">
- Document. onkeydown = chang_page; function chang_page (e ){
- Var e = e | event,
- Keycode = e. which | e. keyCode;
- If (keycode = 33 | keycode = 37) location = '<? Php echo get_previus_posts_page_link ();?> ';
- If (keycode = 34 | keycode = 39) location = '<? Php echo get_next_posts_page_link ();?> ';
- }
- </Script>
- <? Php }?>
- <? Php wp_reset_query (); if (is_single () {?>
- <Script type = "text/javascript">
- Document. onkeydown = chang_page; function chang_page (e ){
- Var e = e | event,
- Keycode = e. which | e. keyCode;
- If (keycode = 33 | keycode = 37) location = '<? Php echo get_permalink (get_adjacent_post (false, '', false);?> ';
- If (keycode = 34 | keycode = 39) location = '<? Php echo get_permalink (get_adjacent_post (false, '', true);?> ';
- }
- </Script>
- <? 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