How To Redirect Back To The Referring Page After Login In WordPress

1 |
<a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a> |
OR
Add this code to your functions.php
file in your WordPress theme…
1 2 3 4 5 6 7 8 |
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['login_location']) && !empty($_POST['login_location'])) ) { add_filter('login_redirect', 'my_login_redirect', 10, 3); function my_login_redirect() { $location = $_SERVER['HTTP_REFERER']; wp_safe_redirect($location); exit(); } } |
Leave Your Comment
All fields marked with "*" are required.