Create HTML back button and link

HTML Zurueck Button und Link erstellen inkl. Einbau in WordPress
Contents

    The jump to the previous page can be implemented as a text link, for example. To do this, the following code must be inserted into the HTML:

    <a href="javascript:history.back()">Back</a>

    HTML back button displayed as a button

    If the back button should actually be displayed as a button, you can enable this with the following HTML code:

    <input type="button" value="Back" onClick="javascript:history.back()">

    Installing the back button in WordPress

    You can of course also integrate the above button or code snippet into WordPress. However, it is important to know that you must not insert the code snippet in the text editor in “visual” mode, but must first switch the editor to “text” mode (top right). You can only insert HTML code in text mode.

    Alternatively, you can also integrate the button via shortcode.

    HTML back button as shortcode for WordPress

    Insert the following code snippet into your functions.php file of your (child) theme:

    function add_back_button_shortcode() {
    return '<a href="javascript:history.back();">Zurück</a>';
    }
    add_shortcode( 'back_button', 'add_back_button_shortcode' );

    Then you can use the shortcode [back_button] to insert the back button into your WordPress page.


    Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

    Updated on 29. March 2024
    Was this article helpful?

    Leave a Reply

    Your email address will not be published. Required fields are marked *