To change the WordPress login logo, you can create a simple plugin that uses the login_enqueue_scripts
hook to add a custom CSS file to the login page. Here’s an example code:
- Create a new folder in your WordPress plugins directory and name it something like “custom-login-logo”.
- Create a new file in this folder and name it “custom-login-logo.php”.
- Add the following code to the “custom-login-logo.php” file:
<?php
/**
* Plugin Name: Custom Login Logo
* Plugin URI: https://yourwebsite.com/
* Description: Changes the WordPress login logo
* Version: 1.0
* Author: Your Name
* Author URI: https://yourwebsite.com/
*/
function custom_login_logo() {
// Replace "logo.png" with the name of your custom logo file
$logo_url = plugin_dir_url( __FILE__ ) . 'logo.png';
echo '<style type="text/css">
#login h1 a {
background-image: url(' . $logo_url . ');
background-size: contain;
width: 100%;
}
</style>';
}
add_action( 'login_enqueue_scripts', 'custom_login_logo' );
- Save the file.
- Create a new image file for your custom logo and save it in the plugin folder.
- Activate the plugin in the WordPress admin panel.
- Refresh the login page, and you should see your custom logo displayed instead of the default WordPress logo.
Note: Make sure that your custom logo file is in a suitable format and size for your needs.