Thay đổi logo, đường dẫn trên logo và style lại trang đăng nhập admin WordPress

clock 14:03

Copy đoạn mã này vào file functions.php trong theme mà bạn đang sử dụng:


/**
 * Custom login logo
 */
function custom_login_logo() { ?>
    <style type="text/css">
		body,
		#wp-submit,
		#wp-submit:hover,
		#wp-submit:focus,
		#wp-submit:visited { 
			background: #4C4C4C !important;
		}
		body a,
		.login form { 
			color: #FFF !important; 
		}
		body a:focus,
		#language-switcher input[type="submit"]:focus {
			box-shadow: none !important;
		}
		body {
			height: 100vh;
			display: flex;
			flex-direction: column;
			justify-content: center;
		}
		#wp-submit,
		#wp-submit:hover,
		#wp-submit:focus,
		#wp-submit:visited {
			box-shadow: none !important;
			border-color: #F34636 !important;
		}
		#language-switcher {
			display: none;
			background: none !important;
		}
		#language-switcher input[type="submit"] {
			color: #FFF !important;
			border-color: #AA1809 !important;
			background: #AA1809 !important;
		}
		#language-switcher,
		#login-message,
		#login_error,
		.message {
			display: none;
		}
		#login {
			width: 750px !important;
			max-width: 100% !important;
		}
		#login h1 {
			margin-left: 24px;
			padding: 0 24px;
			height: 252px;
			float: left;
			display: flex;
			align-items: center;
			background-color: #D7D7D7;
		}
        #login h1 a, .login h1 a {
			width: 225px; 
			height: 150px;
            background-image: url('/img/admin-logo.png'); // thay bằng đường dẫn logo của bạn
			background-size: 225px 150px;
        }
		#login h1 a {
			margin-bottom: 0;
		}
		#lostpasswordform {
			height: 192px;
		}
		.login form {
			margin-top: 0 !important;
			margin-right: 24px !important;
			border: none !important;
			background: #F67D20 !important;
		}
		.admin-email-confirm-form {
			padding: 5px 20px !important;
			height: 242px !important;
			overflow-y: scroll !important;
		}
		.admin-email-confirm-form .admin-email__heading {
			width: 100% !important;
			height: auto !important;
			margin-left: 0 !important;
			padding: 0 !important;
			color: #FFF !important;
			border-bottom: none !important;
			background: none !important;
		}
		.admin-email__actions-primary .button-large {
			border: none !important;
			background: #4C4C4C !important;
		}
		@media (max-width: 768px) {
			#login h1,
			#lostpasswordform {
				height: auto;
			}
			#login h1 {
				margin-right: 24px;
				padding: 20px;
				height: auto;
				float: none;
			}
			.login form {
				margin-left: 24px !important;
			}
			.admin-email-confirm-form {
				padding: 20px !important;
				height: auto !important;
			}
		}
    </style>
<?php }
add_action( 'login_enqueue_scripts', 'custom_login_logo' );

function custom_login_url($url) {
    return 'https://haidm.dev'; // thay bằng url của bạn
}
add_filter( 'login_headerurl', 'custom_login_url' );

Chúc các bạn thành công.

0 0 đánh giá
Đánh giá bài viết
Theo dõi
Thông báo của
guest
0 Góp ý
Cũ nhất
Mới nhất Được bỏ phiếu nhiều nhất