Want to display a custom message on your WordPress login page? We’ll walk you through adding a custom login message to WordPress’ wp-login.php
page. We’ll use existing styling provided in WordPress core, and the login_message
filter to make it all happen.
Adding a WordPress Custom Login Message to wp-login.php
You could add this code directly to your theme’s functions.php
file, but I prefer to use the Code Snippets plugin. The Code Snippets plugin allows you to create custom functionality on your WordPress site using actions & filters, without the need to sort through a bunch of code in your functions.php
file. It’s a much safer and more manageable way to insert custom code.
Here’s the code that will add a custom login message to your login page in WordPress:
/* Add message above login form */
function wpsd_add_login_message() {
return '<p class="message">Use this form to login to the administration area of WordPress, and make changes to your website.</p>';
}
add_filter('login_message', 'wpsd_add_login_message');
We’re creating a function called wpsd_add_login_message
, and adding it to the wp-login.php
page using the filter, login_message
. We use a class of .message
so the text uses WordPress’ core styling for message blocks. You can choose to omit that if you’d like, or add your own styling.
You can include any HTML markup you’d like. You’re not limited to a <p>
tag.
Whatever you choose to add to your custom login message, it will be rendered directly above the <form id="loginform" ... >
tag.
<form>
tag on wp-login.php.We Recommend
https://kinsta.com › wordpress-hosting
Fast and secure infrastructure, worldwide CDN, edge caching, 35 data centers, and enterprise-level features included in all plans. Free site migrations.
https://gravityforms.com › features
Create custom web forms to capture leads, collect payments, automate your workflows, and build your business online. All without ever leaving WordPress.
Leave a Comment