How to Add a Custom Message to the WordPress Login Screen

Home » Snippets » How to Add a Custom Message to the WordPress Login Screen
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Are you bored with the default WordPress login screen? Want to add some personality to your site by displaying a custom message or branding on the login screen? In this article, we’ll show you how to add a custom message to your WordPress login screen, allowing you to add a personal touch and make your site stand out to your visitors.

					function wpturbo_custom_login_message() {
    $message = "<p class='wpturbo-custom-message'>" . __( 'Your custom message goes here.', 'wpturbo' ) . "</p>";
    return $message;
}
add_filter( 'login_message', 'wpturbo_custom_login_message' );
				

The code snippet provided is used to add a custom message to the login screen on a WordPress site. The message will appear between the login form and the "Lost your password?" link.

The first step is to define a function named wpturbo_custom_login_message(). Inside the function, we create a variable called $message and set its value to a string that contains the custom message we want to display on the login screen. We use the WordPress __() function to make the message translatable.

$message = "<p class='wpturbo-custom-message'>" . __( 'Your custom message goes here.', 'wpturbo' ) . "</p>";

In this example, we have used a <p> tag to wrap the custom message and a class of ‘wpturbo-custom-message’ to style it later with CSS.

The last step is to hook the wpturbo_custom_login_message() function into the login_message filter using the add_filter() function. The filter accepts a message string, modifies it using the function, and returns the new message to be displayed on the login screen.

add_filter( 'login_message', 'wpturbo_custom_login_message' );

By adding this filter, the custom message defined in the wpturbo_custom_login_message() function will be displayed on the login screen of the WordPress site.

Register an account to save your snippets or go Pro to get more features.