I've created a custom login page where users can login on my website, but when I try to log in, it's redirected to wp-login.php and I have to enter a reCAPTCHA (I hate those!).

I've already tried to redict wp-login.php to my custom login page, which works, but the outcome is that now I'm in an infinite loop of redirecting to the same custom login page and not being able to actually log in.

How can I do this?


My custom login page looks exactly like this:

<?php get_header(); ?>
<div class="container">
<div class="row" style="margin:1em 0;">
    <div class="col-12 login-page">
        if ( ! is_user_logged_in() ) {
            $args = array(
                'redirect' => home_url(), 
                'form_id' => 'main-login',
                'label_username' => 'Gebruikersnaam',
                'label_password' => 'Wachtwoord',
                'label_remember' => 'Onthoud mij',
                'label_log_in' => 'Inloggen',
                'value_remember' => true,
                'remember' => true
            wp_login_form( $args );
        } else {
            echo '<p style="text-align:center">' . wp_get_current_user()->user_firstname . '? Je bent al ingelogd. Ga maar wat Netflixen!</p><p style="text-align:center">Wil je uitloggen? Dat kan door <a href="https://www.telecinegids.be/wp-login.php?action=logout&redirect_to=https%3A%2F%2Fwww.myurl.be&_wpnonce=nonce">hier</a> te klikken.</p>';
<?php get_footer();

1 Answer 1


It's all well and good to build a login page, but you need some way to tell WP to actually use your custom page.

Luckily, there is a way to do that, with a filter (of course):

function redirect_login_page() {
  // your login page code

Put your code (or call a template) inside the function. And place the above code in your functions.php (in your Child Theme, hopefully, since you don't want a theme update to overwrite your custom code on a theme update).

More details are available here https://premium.wpmudev.org/blog/customize-login-page/ and in the Codex https://codex.wordpress.org/Function_Reference/wp_login_form, plus lots of other resources about customizing the login page on the googles.

  • Thank you for your suggestion. But in my case, I'm not really liking this solution. I'll always have to refer to /wp-login.php when a custom page seems more professional + my custom css is not included in that admin section hence the layout is not clean. Also still the same reCAPTCHA 'issue'.
    – Stef
    Nov 15, 2018 at 21:47
  • I believe this will work. For every page that has a 'login' link, the filter will redirect the login link to the code in the function (which can be your own login page). Even if the visitor requests wp-login.php, your code (and your login page) will be executed. And since your login page will be used, then a reCAPTCHA should not be seen, unless 'forced' in by another plugin, or by your login page. Nov 15, 2018 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.