Custom Login Page Wordpress


Staff member
I am trying to create a custom login page template for my Wordpress website so I have used the code from codex (<a href="" rel="nofollow noreferrer"></a>) but I don't know how to change the redirect when the user put wrong username or password. It sends the user to the default wp-login page.
How can I redirect the user to my custom login page but with an error message?

P.S.: I am a self-taught coder and I know almost nothing about PHP.

 * Template Name: login page 

&lt;?php get_header(); ?&gt; 

    if ( ! is_user_logged_in() ) { // Display WordPress login form:
        $args = array(
            'redirect' =&gt; admin_url(),
            'form_id' =&gt; 'student-loginform',
            'label_username' =&gt; __( 'Username' ),
            'label_password' =&gt; __( 'Password' ),
            'label_remember' =&gt; __( 'Lembrar-me' ),
            'label_log_in' =&gt; __( 'Log In' ),
            'remember' =&gt; true,
            'echo' =&gt; true,

    wp_login_form( $args );

    } else { // If logged in:
        wp_loginout( home_url() ); // Display "Log Out" link.
        echo " ";

&lt;?php get_footer(); ?&gt;