Archived topic
block element - post navigation by keyboard
9 replies · Started by Boris on April 8, 2022
Dear Team,
Is there a way to add post-navigation with the computer keyboard: "previous/next" "< >" for Block Element?
Thanks and best regards,
Boris
Hi there,
I am not sure I understand.
Are you wanting to allow users too use Keyboard control of the navigation ?
Hi David,
Thanks for asking.
Yes, navigation with the left-right arrow keys.
The code provided here should still work:
Its a PHP Snippet - this doc explains how to add to the site:
https://docs.generatepress.com/article/adding-php/
Thanks David,
I will try it - and will let you know.
Best regards,
Boris
Please do :)
Hi David,
Thanks for the support.
It works! The users can now navigate from post to post using the keyboard. Now my question is, how can the function be defined/restricted for certain post categories? And even better: could i define if it works in carousel mode (like for a slider) or not, is that possible?
Thanks and best regards,
Boris
You can limit to the 'same category' as the current post.
In the code look for:
get_previous_post() and get_next_post()
change it to:
get_previous_post(true) and get_next_post(true)
The carousel/slider function isn't something I can help with - that would require a plugin or custom development
Hi David,
Thank you for the prompt reply!
Unfortunately, I can't use the code to limit / to connect the Keyboard-navigation-function to one post category.
I'll look for other solutions now...
Thanks and best regards,
Boris
No problem, sorry I could provide a solution, I hope you find one!