-
sascha
Hi
I need to place a “Back” button at the bottom of each single post. I wil do this via GP-Elements, but not familiar with JS, which seems to be required in order to provide a back-nav-function to a button.
Is this something you can help me with?
Thank you in advance and kind regards
Sascha -
Hi there,
try this for your JS
<script> const goBackBtn = document.querySelector('.go-back'); goBackBtn.addEventListener('click', goBack); function goBack() { window.history.back(); } </script>
Then add the
go-back
class to your button.Then you can add the
go-back
-
sascha
Thanks David.
So I add the code via Element, Custom Hook “go-back” and add “go-back as a class to the button?
-
David’s code can be added by creating a hook element with the
wp_footer
hook:
https://docs.generatepress.com/article/hooks-element-overview/
https://docs.generatepress.com/article/wp_footer/And yes the
go-back
class can be added here:
https://docs.generateblocks.com/article/advanced-options-overview/#additional-CSS-Class
- You must be logged in to reply to this topic.