How to Create a WordPress Custom Login Page Without Creating a Custom Page and Redirection

Many WordPress sites often overlook thelogin pageThe importance of thelogin pageIt is the user's first interaction with the website. A default or poorly designed WordPress custom login page can degrade the user experience.

A well-designed login page not only impresses your customers, but also enhances security. In this article, we will introduce two effective ways to customize the WordPress login page: modifying the functions.php file and applying custom CSS.

Images[1] - How to customize and protect WordPress login page: simple and effective methods

Why do I need to customize my WordPress login page?

Some people may wonder if the customization of the login page is worth the time investment, especially if the list of tasks is already long. There are several reasons regarding this aspect of optimization:

Website Branding & Design
The login page is the user's first impression and it should be consistent with the overall look and feel of the website. This is accomplished through theCustom colors, fonts, logosrespond in singingopening (chess jargon)that can create a unified brand experience for users (especially loyal customers).

Enhancing the user experience
A well-designed login page enhances the user experience. A simple and easy-to-use interface engages users, while cluttered or difficult to understand pages may drive users away. Investing time in optimizing the login experience can significantly improve user satisfaction.

Improve website security
Securing your website is crucial. Customizing the login page is an effective security measure to reduce the likelihood of your website being attacked by hiding the default WordPress login page and changing its URL. This not only reduces unauthorized access, but also increases user trust in your website.

Ways to customize the default wp-login.php page

There are several ways to modify the WordPress login page. If you don't want to create a separate page, we'll focus on two simple ways to customize it:

Customize the wp-login.php page via the functions.php file

Use the theme's functions.php fileWhen modifying the default WordPress login page, it is recommended that you create a test environment first to avoid interfering with the normal operation of the online site.

Here are the exact steps:

  1. Entering the test environment
    Access the new application via SSH and confirm which theme is currently in use. In this example, we're using the twenty-twenty-four Topics.
  2. Find the Theme Catalog
    The subject directory is usually located:
    /home/master/applications/appname/public_html/wp-content/themes/twentytwentyfour
  3. Edit the functions.php file
    Open with a text editor functions.php file, add the required code at the end of the file.

take note of: Editing the functions.php file directly is risky. It is recommended to createsubtheme, isolate the custom code to avoid causing problems when the theme is updated.

Images [2] - How to Customize and Secure WordPress Login Page: Simple and Effective Methods

Here is functions.phpThe code for the file:

// Add custom CSS to the login page
function custom_login_styles() {
function custom_login_styles() { <style
body.login {
background-color: #141414; /* Dark background */
color: #ffffff; /* White text color */
font-family: 'Arial', sans-serif; /* Font style */
}
.login h1 a {
background-image: url('/images/logo.png'); /* Your logo if needed */ } .login h1 a { background-image: url('<?
background-size: contain; background-repeat: no-repeat; /* Your logo if needed */
height: 80px; /* Adjust height */
display: block;
margin: 0 auto; /* Adjust height */ display: block; margin: 0 auto; }
}
.login form {
background-color: rgba(255, 255, 255, 0.1); /* Slightly transparent white background */
padding: 40px; border-radius: 10px
border-radius: 10px; /* Rounded corners */
box-shadow: 0 0 20px rgba(0, 0, 0, 0, 0.5); /* Shadow for depth */
margin: 0 auto; /* Center the form */
max-width: 400px; /* Set a maximum width for the form */
}
.login label {
color: #ffffff; /* White label text */
}
.login input[type="text"], /* white label text */ }
.login input[type="password"] {
border: 1px solid #ffffffff; /* White border for inputs */
border-radius: 5px; /* Rounded corners */
padding: 10px; /* Padding for inputs */
width: 100%; /* Full width */
margin-bottom: 20px; /* Space between inputs */
background-color: rgba(255, 255, 255, 0.2); /* Full width */ color: #ffff; /* Space between inputs */
color: #ffffff; /* White text color */
}
.login #wp-submit {
background-color: #e50914; /* red */
background-color: #e50914; /* red */ border: none; /* Remove border */
color: #ffffff; /* White text color */
cursor: pointer; /* Pointer on hover */
padding: 10px; /* Padding for button */
width: 100%; /* Full width */
border-radius: 5px; /* Rounded corners */
}
.login #wp-submit:hover {
background-color: #f40612; /* Red on hover */
}
#nav {
text-align: center; /* Center the navigation links */ } #nav { text-align: center; /* Center the navigation links */
font-size: 12px; /* Make the font smaller */
margin-top: 20px; /* Space above the links */ }
}
#nav a {
color: #e50914; /* Red */ text-decoration: none; //
text-decoration: none; /* Remove underline */
}
#nav a:hover {
text-decoration: underline; /* Underline on hover */
}
</style
<?php
}
add_action('login_head', 'custom_login_styles');
// Add custom CSS to the login page
function custom_login_styles() {
    function custom_login_styles() { <style
    
        body.login {
            background-color: #141414; /* Dark background */
            color: #ffffff; /* White text color */
            font-family: 'Arial', sans-serif; /* Font style */
        }
        .login h1 a {
            background-image: url('/images/logo.png'); /* Your logo if needed */ } .login h1 a { background-image: url('<?
            background-size: contain; background-repeat: no-repeat; /* Your logo if needed */
            
            
            height: 80px; /* Adjust height */
            display: block;
            margin: 0 auto; /* Adjust height */ display: block; margin: 0 auto; }
        }
        .login form {
            background-color: rgba(255, 255, 255, 0.1); /* Slightly transparent white background */
            padding: 40px; border-radius: 10px
            border-radius: 10px; /* Rounded corners */
            box-shadow: 0 0 20px rgba(0, 0, 0, 0, 0.5); /* Shadow for depth */
            margin: 0 auto; /* Center the form */
            max-width: 400px; /* Set a maximum width for the form */
        }
        .login label {
            color: #ffffff; /* White label text */
        }
        .login input[type="text"], /* white label text */ }
        .login input[type="password"] {
            border: 1px solid #ffffffff; /* White border for inputs */
            border-radius: 5px; /* Rounded corners */
            padding: 10px; /* Padding for inputs */
            width: 100%; /* Full width */
            margin-bottom: 20px; /* Space between inputs */
            background-color: rgba(255, 255, 255, 0.2); /* Full width */ color: #ffff; /* Space between inputs */
            color: #ffffff; /* White text color */
        }
        .login #wp-submit {
            background-color: #e50914; /* red */
            background-color: #e50914; /* red */ border: none; /* Remove border */
            color: #ffffff; /* White text color */
            cursor: pointer; /* Pointer on hover */
            padding: 10px; /* Padding for button */
            width: 100%; /* Full width */
            border-radius: 5px; /* Rounded corners */
        }
        .login #wp-submit:hover {
            background-color: #f40612; /* Red on hover */
        }
        #nav {
            text-align: center; /* Center the navigation links */ } #nav { text-align: center; /* Center the navigation links */
            font-size: 12px; /* Make the font smaller */
            margin-top: 20px; /* Space above the links */ }
        }
        #nav a {
            color: #e50914; /* Red */ text-decoration: none; //
            text-decoration: none; /* Remove underline */
        }
        #nav a:hover {
            text-decoration: underline; /* Underline on hover */
        }
    </style
    <?php
}
add_action('login_head', 'custom_login_styles');
// Add custom CSS to the login page function custom_login_styles() { function custom_login_styles() { <style body.login { background-color: #141414; /* Dark background */ color: #ffffff; /* White text color */ font-family: 'Arial', sans-serif; /* Font style */ } .login h1 a { background-image: url('/images/logo.png'); /* Your logo if needed */ } .login h1 a { background-image: url('<? background-size: contain; background-repeat: no-repeat; /* Your logo if needed */ height: 80px; /* Adjust height */ display: block; margin: 0 auto; /* Adjust height */ display: block; margin: 0 auto; } } .login form { background-color: rgba(255, 255, 255, 0.1); /* Slightly transparent white background */ padding: 40px; border-radius: 10px border-radius: 10px; /* Rounded corners */ box-shadow: 0 0 20px rgba(0, 0, 0, 0, 0.5); /* Shadow for depth */ margin: 0 auto; /* Center the form */ max-width: 400px; /* Set a maximum width for the form */ } .login label { color: #ffffff; /* White label text */ } .login input[type="text"], /* white label text */ } .login input[type="password"] { border: 1px solid #ffffffff; /* White border for inputs */ border-radius: 5px; /* Rounded corners */ padding: 10px; /* Padding for inputs */ width: 100%; /* Full width */ margin-bottom: 20px; /* Space between inputs */ background-color: rgba(255, 255, 255, 0.2); /* Full width */ color: #ffff; /* Space between inputs */ color: #ffffff; /* White text color */ } .login #wp-submit { background-color: #e50914; /* red */ background-color: #e50914; /* red */ border: none; /* Remove border */ color: #ffffff; /* White text color */ cursor: pointer; /* Pointer on hover */ padding: 10px; /* Padding for button */ width: 100%; /* Full width */ border-radius: 5px; /* Rounded corners */ } .login #wp-submit:hover { background-color: #f40612; /* Red on hover */ } #nav { text-align: center; /* Center the navigation links */ } #nav { text-align: center; /* Center the navigation links */ font-size: 12px; /* Make the font smaller */ margin-top: 20px; /* Space above the links */ } } #nav a { color: #e50914; /* Red */ text-decoration: none; // text-decoration: none; /* Remove underline */ } #nav a:hover { text-decoration: underline; /* Underline on hover */ } </style <?php } add_action('login_head', 'custom_login_styles');

The provided code will modify the default appearance of the login page. The CSS can now be customized to achieve the desired effect.

Images [3] - How to Customize and Secure WordPress Login Page: Simple and Effective Methods

Modifying wp-login.php with custom CSS

The WordPress login page can be highly customized by injecting custom CSS into the wp-login.php file. However, this method should be used with caution, as modifying WordPress core files directly may cause problems, especially if you are unfamiliar with CSS or WordPress development.

To safely try this method, it is recommended to create a test environment.

The specific steps are as follows:

Preparing the test site
After creating your test site, visit and find the exact path to the wp-login.php file. Typically, this file is located in the WordPress root directory.

Backup the original file
Prior to making changesBackup the wp-login.php file first.It can be renamed to something like wp-login-original.php The name of the

Test modifications
Thoroughly test your changes in a test environment to make sure there are no problems before applying them to the online site.

take note of: Direct modification of the core file risk is high, before using this method is recommended to weigh carefully, but also to ensure that the modified site functions and styles of normal operation.

Images [4] - How to Customize and Secure WordPress Login Page: Simple and Effective Methods

Next, go to the application's public_html Folder. Here you can find the wp-login.php Documentation.

Images [5] - How to Customize and Secure WordPress Login Page: Simple and Effective Methods

The supplied code needs to be placed directly in the wp-login.php documentation <head> tag between the start and end tags. Normally, this code should be located at the very top of the file.

Images [6] - How to Customize and Secure WordPress Login Page: Simple and Effective Methods

locate wp-login.php Papers <head> portion of the existing code and completely replace it with the new code provided.

Here's the code:

?><!DOCTYPE html>
<html no numeric noise key 1004>
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<title><?php wp_title(); ?></title>
<link rel="stylesheet" href="<?php echo includes_url('css/login.css'); ?>" type="text/css" />
<style>
body.login {
background-color: #ffffff; /* Complete background white */
font-family: Arial, sans-serif; /* Change font */
}
.login h1 {
text-align: center; /* Center the logo */
margin-bottom: 20px; /* Space below the logo */
}
.login h1 a {
background-image: url('<?php echo get_stylesheet_directory_uri(); ?>'); /* Add your logo as required */
background-size: contain;
background-repeat: no-repeat;
width: 100%; /* Make the logo full width */
height: 80px; /* Adjust height */
display: block;
}
.login form {
background-color: #d3d3d3; /* Grey background for the form */
padding: 26px;
border-radius: 5px; /* Rounded corners */
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Add shadow */
margin: 0 auto; /* Center the form */
max-width: 400px; /* Set a maximum width for the form */
}
.login label {
font-weight: bold; /* Bold labels */
color: orange; /* Change label color to orange */
}
.login input[type="text"],
.login input[type="password"] {
border: 1px solid #ddd; /* Border for inputs */
border-radius: 3px; /* Rounded corners */
padding: 10px; /* Padding for inputs */
width: 100%; /* Full width */
}
.login #wp-submit {
background-color: #007cba; /* Button color */
border: none; /* Remove border */
color: #fff; /* Text color */
cursor: pointer; /* Pointer on hover */
padding: 10px; /* Padding for button */
width: 100%; /* Full width */
}
.login #wp-submit:hover {
background-color: #006ba1; /* Darker button on hover */
}
.custom-message {
color: orange; /* Change custom message font color to orange */
text-align: center; /* Center the message */
margin-bottom: 20px; /* Space below the message */
}
#nav {
text-align: center; /* Center the navigation links */
font-size: 12px; /* Make the font smaller */
margin-top: 20px; /* Space above the links */
}
#nav a {
color: #007cba; /* Change link color */
text-decoration: none; /* Remove underline */
}
#nav a:hover {
text-decoration: underline; /* Underline on hover */
}
</style>
</head>
        ?><!DOCTYPE html>                                                                                                                                               
        <html no numeric noise key 1004>                                                                                                                          
<head>                                                                                                                                                                  
    <meta charset="<?php bloginfo('charset'); ?>" />                                                                                                                    
    <title><?php wp_title(); ?></title>                                                                                                                                 
    <link rel="stylesheet" href="<?php echo includes_url('css/login.css'); ?>" type="text/css" />                                                                       
<style>                                                                                                                                                                 
      body.login {                                                                                                                                                      
        background-color: #ffffff; /* Complete background white */                                                                                                      
        font-family: Arial, sans-serif; /* Change font */                                                                                                               
    }                                                                                                                                                                   
    .login h1 {                                                                                                                                                         
        text-align: center; /* Center the logo */                                                                                                                       
        margin-bottom: 20px; /* Space below the logo */                                                                                                                 
    }                                                                                                                                                                   
    .login h1 a {                                                                                                                                                       
        background-image: url('<?php echo get_stylesheet_directory_uri(); ?>'); /* Add your logo as required */                                                                     
        background-size: contain;                                                                                                                                       
        background-repeat: no-repeat;                                                                                                                                   
        width: 100%; /* Make the logo full width */                                                                                                                     
        height: 80px; /* Adjust height */                                                                                                                               
        display: block;                                                                                                                    
    }                                                                                                                                                                   
    .login form {                                                                                                                                                       
        background-color: #d3d3d3; /* Grey background for the form */                                                                                                   
        padding: 26px;                                                                                                                                                  
        border-radius: 5px; /* Rounded corners */                                                                                                                       
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Add shadow */                                                                                                       
        margin: 0 auto; /* Center the form */                                                                                                                           
        max-width: 400px; /* Set a maximum width for the form */                                                                                                        
    }                                                                                                                                                                   
    .login label {                                                                                                                                                      
        font-weight: bold; /* Bold labels */                                                                                                                            
        color: orange; /* Change label color to orange */                                                                                                               
    }                                                                                                                                                                   
    .login input[type="text"],                                                                                                                                          
    .login input[type="password"] {                                                                                                                                     
        border: 1px solid #ddd; /* Border for inputs */                                                                                                                 
        border-radius: 3px; /* Rounded corners */                                                                                                                       
        padding: 10px; /* Padding for inputs */                                                                                                                         
        width: 100%; /* Full width */                                                                                                                                   
    }                                                                                                                                                                   
    .login #wp-submit {                                                                                                                                                 
        background-color: #007cba; /* Button color */                                                                                                                   
        border: none; /* Remove border */                                                                                                                               
        color: #fff; /* Text color */                                                                                                                                   
        cursor: pointer; /* Pointer on hover */                                                                                                                         
        padding: 10px; /* Padding for button */                                                                                                                         
        width: 100%; /* Full width */                                                                                                                                   
    }                                                                                                                                                                   
    .login #wp-submit:hover {                                                                                                                                           
        background-color: #006ba1; /* Darker button on hover */                                                                                                         
    }                                                                                                                                                                   
    .custom-message {                                                                                                                                                   
        color: orange; /* Change custom message font color to orange */                                                                                                 
        text-align: center; /* Center the message */                                                                                                                    
        margin-bottom: 20px; /* Space below the message */                                                                                                              
    }                                                                                                                                                                   
    #nav {                                                                                                                                                              
        text-align: center; /* Center the navigation links */                                                                                                           
        font-size: 12px; /* Make the font smaller */                                                                                                                    
        margin-top: 20px; /* Space above the links */                                                                                                                   
    }                                                                                                                                                                   
    #nav a {                                                                                                                                                            
        color: #007cba; /* Change link color */                                                                                                                         
        text-decoration: none; /* Remove underline */                                                                                                                   
    }                                                                                                                                                                   
    #nav a:hover {                                                                                                                                                      
        text-decoration: underline; /* Underline on hover */                                                                                                            
    }                                                                                                                                                                   
</style>                                                                                                                                                                
</head>
?><!DOCTYPE html> <html no numeric noise key 1004> <head> <meta charset="<?php bloginfo('charset'); ?>" /> <title><?php wp_title(); ?></title> <link rel="stylesheet" href="<?php echo includes_url('css/login.css'); ?>" type="text/css" /> <style> body.login { background-color: #ffffff; /* Complete background white */ font-family: Arial, sans-serif; /* Change font */ } .login h1 { text-align: center; /* Center the logo */ margin-bottom: 20px; /* Space below the logo */ } .login h1 a { background-image: url('<?php echo get_stylesheet_directory_uri(); ?>'); /* Add your logo as required */ background-size: contain; background-repeat: no-repeat; width: 100%; /* Make the logo full width */ height: 80px; /* Adjust height */ display: block; } .login form { background-color: #d3d3d3; /* Grey background for the form */ padding: 26px; border-radius: 5px; /* Rounded corners */ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Add shadow */ margin: 0 auto; /* Center the form */ max-width: 400px; /* Set a maximum width for the form */ } .login label { font-weight: bold; /* Bold labels */ color: orange; /* Change label color to orange */ } .login input[type="text"], .login input[type="password"] { border: 1px solid #ddd; /* Border for inputs */ border-radius: 3px; /* Rounded corners */ padding: 10px; /* Padding for inputs */ width: 100%; /* Full width */ } .login #wp-submit { background-color: #007cba; /* Button color */ border: none; /* Remove border */ color: #fff; /* Text color */ cursor: pointer; /* Pointer on hover */ padding: 10px; /* Padding for button */ width: 100%; /* Full width */ } .login #wp-submit:hover { background-color: #006ba1; /* Darker button on hover */ } .custom-message { color: orange; /* Change custom message font color to orange */ text-align: center; /* Center the message */ margin-bottom: 20px; /* Space below the message */ } #nav { text-align: center; /* Center the navigation links */ font-size: 12px; /* Make the font smaller */ margin-top: 20px; /* Space above the links */ } #nav a { color: #007cba; /* Change link color */ text-decoration: none; /* Remove underline */ } #nav a:hover { text-decoration: underline; /* Underline on hover */ } </style> </head>

The provided code generates a base style for the website login page. Different CSS properties and values can be experimented with to achieve the look and feel you want.

Image [7] - How to customize and protect WordPress login page: simple and effective methods

Protecting WordPress Login Pages

Security also needs to be prioritized when customizing the login page. Here are some tips for securing your WordPress login page:

  1. Limit the number of login attempts: Limit the number of login attempts for a single IP address with the plug-in.
  2. Enable two-factor authentication: Adding additional layers of security can be effective in preventing unauthorized access.
  3. Changing the login URL: Consider using a plugin to change the default login URL from /wp-login.php Change to another address.

summarize

This article describes two ways to customize your WordPress login page without the complexity of creating a separate page or redirection. Modify functions.php file or applying custom CSS, you can align the WordPress login page with your website's branding and improve the overall user experience.


Contact Us
Can't read the article? Contact us for free answers! Free help for personal, small business sites!
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
This article was written by Banner1
THE END
If you like it, support it.
kudos12 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments