Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #696238

    Can you advise in which child theme file i need to add the code discussed here to add hotkeys for previous/next post

    https://techglimpse.com/create-keyboard-navigation-for-your-website/

    • This topic was modified 8 years, 1 month ago by yingyang.
    #696971

    Hey kilimats!

    Thank you for using Enfold.

    Please add this in the functions.php file:

    // custom script
    add_action( 'wp_footer', 'ava_custom_script' );
    function ava_custom_script() {
    	?>
    	<script type="text/javascript">
    	(function($) {
    		function a() {
    		    jQuery(document).keydown(function(e) {
    		        var url = false;
    		        if (e.which == 37) {  // Left arrow key code
    		            url = jQuery('.avia-post-prev').attr('href');
    		        }
    		        else if (e.which == 39) {  // Right arrow key code
    		            url = jQuery('.avia-post-next').attr('href');
    		        }
    		        if (url) {
    		            window.location = url;
    		        }
    		    });
    		}
    
    		a();
    	})(jQuery);
    	</script>
    	<?php
    }

    Best regards,
    Ismael

    #696974

    you guys rock !! thank you !!

    #696985

    Hi,

    Glad we could help.

    Thank you for using Enfold :)

    Best regards,
    Vinay

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Adding previous/next keyboard shortcut’ is closed to new replies.