Code thay logo trang đăng nhập WordPress

4.8/5 – (149 bình chọn)

Hôm nay mình xin chia sẻ đoạn code để thay đổi logo trang đăng nhập của wordpress.

Các bạn copy đoạn code sau vào functions.php của theme đăng dùng

add_action( 'login_enqueue_scripts', 'sgd_login_logo' );
 
function sgd_login_logo() {
   ?>
    <style type="text/css">
        #login h1 a, .login h1 a {
           background-image: url(/wp-content/uploads/2020/03/PNG-RGB-1536x830.png);
           height: 150px;
           width: 250px;
           background-size: contain;
           background-repeat: no-repeat;
           background-color: transparent;
      }
    </style>
   <?php
}
 
add_filter( 'login_headerurl', 'sgd_login_logo_link' );
 
function sgd_login_logo_link( $url ) {
    return home_url( '/' );
}

Các bạn nhớ thay đoạn /wp-content/uploads/2020/03/PNG-RGB-1536x830.png thành link ảnh mình muốn nhé. Size ảnh là 250 x 150 px.

Thành quả demo

Hy vọng với code này có thể giúp các bạn đổi logo trang đăng nhập mà không cần dùng tới plugin

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *