Change WordPress logo on login page without plugin – Learn WordPress from a to z

Tutorials 0 lượt xem

Normally, WordPress provides a default logo on the Login, Register, Forgot Password… But it is better to replace that default WordPress logo with your own for better branding for your website. your website.

So, in this article I will show you how to change your WordPress login logo without a plugin. Let’s get It Started!

Change WordPress login logo

As an alternative, I need to override the default logo on the WordPress Login page. I will use hook login_enqueue_scripts . As the name suggests, it is used to add script code or styles to the login page.

/*@ Change WordPress Admin Login Logo */
if ( !function_exists('hk_wp_admin_login_logo') ) :
 
    function hk_wp_admin_login_logo() { ?>
        <?php }
 
    add_action( 'login_enqueue_scripts', 'hk_wp_admin_login_logo' );
 
endif;
<div><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span><span>10</span><span>11</span><span>12</span><span>13</span><span>14</span><span>15</span>

In the example above, I replaced the WordPress logo using the CSS background-image attribute . In addition, I use the get_template_directory_uri() function to get my logo path.

Now your job is to change this /assets/images/your-logo.jpg to your logo path.

Change the link of the WordPress login logo

After changing the logo, you also need to change the link of the logo.

WordPress default logo

To do this, I will use the hook filter login_headerurl

/*@ Change WordPress Admin Login Logo Link URL  */
if ( !function_exists('hk_wp_admin_login_logo_url') ) :
 
    function hk_wp_admin_login_logo_url() {
        return home_url();
    }
    add_filter( 'login_headerurl', 'hk_wp_admin_login_logo_url' );
 
endif;
<div>
<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span>
</div>

In the above example, I used the homepage – home_url() to make the link when the user clicks on the logo. You can also change it to any link you want.

Epilogue

I hope you can apply this article in the process of developing a WordPress website. Especially when you need to create a unique brand for your website.

If you found this article useful, please comment and share this article. In addition, you can follow the WordPress Tips section and follow Facebook for more new knowledge.

Bài viết liên quan