Back Button for WordPress

This is a webmaster reference page. To see more webmaster reference pages, use the link below.

Occasionally you will have to RETURN to a previous page, such as Chicken Empanadas and Chicken Tinga. The base for both is Poached Chicken.

Rather than repeating the recipe, I am using a back button, so the chef can click to go to the recipe for Poached Chicken, and then return to the recipe on which they were working.

The basic user: What you will see are three back buttons.

Developers:  These three buttons are coded slightly differently, but the result is the same – they return you to the previously viewed page.  Some will and some will not work with your specific instance of WordPress.  My suggestion to you is to try all three and determine which works best for you.  They must be installed on the Text edit screen, not the Visual edit screen.

NOTE:  WordPress will probably take control and reformat the button to whichever coding standard your particular theme prefers.  Go with it.  The functionality is the same.  Why should you care how WordPress reformats it.

The script which has generated the button is shown AFTER the instances of the button. Please comment below if this page was helpful to you.


<button>Previous Page</button>


<input type=”button” value=”Previous Page” onclick=”goBack()”>


<button onclick=”goBack()”>This is a Go Back Button</button>


All three methods call a JavaScript function called goBack() which must exist on each page featuring the back button. That script is shown below.

<script>
function goBack() {
window.history.back()
}
</script>

WordPress does, however, do some wonky things with the back button and history, so another option (that I eventually used) is to use a plugin called GoBack

 

Copy and paste from below.  You will probably have to reformat the double quotes.  This must be entered in the Text Edit Mode.  If you return to that page, this button will probably break.

<button onclick=”goBack()”>Return to Previous Page</button>

<script>
function goBack() {
window.history.back()
}</script>

 

Print Friendly, PDF & Email
HTML Snippets Powered By : XYZScripts.com