How to Add Back Buttons to Web Pages [closed] (ok)

https://wordpress.stackexchange.com/questions/221640/how-to-add-back-buttons-to-web-pages

if( wp_get_referer() )
  echo '<a href="'<?php wp_get_referer() ?> '" >BACK</a>';

Or

Add into theme functions.php
add_action( 'back_button', 'wpse221640_back_button' );
function wpse221640_back_button(){
  if ( wp_get_referer() && !is_front_page()  ){
    $back_text = __( '&laquo; Back' );
    $button    = "\n<button id='my-back-button' class='btn button my-back-button' onclick='javascript:history.back()'></button>";
    echo ( $button );
  }
}
Add into theme header.php after <body>

<?php do_action('back_button'); ?>

Last updated