Skip to main content
We are Brand SEO Beijing serving international business, your marketing partner, Contact us by mi@mgsh.com.cn

Customize logo/link/text of website user login page

Through the built-in hook (Hook) of the website CMS, add some simple code to the functions.php of the theme to complete the custom modification, all operations do not need to modify the WordPress core files, even if the WordPress version is upgraded, the effect will not be lost .

Custom Logo Image

Make an image named login_logo.png, put it in the images folder under the theme, and pay attention to the address in the code.Location replacement: admin/images/w-logo-blue.png
What if an error is reported?You can try to replace the original logo directly.But is it a bit low to do so, do we as technicians still have to solve the invalid property value error?Search this site for invalid and you will find the answer.

//Customize the logo image of the login page function my_custom_login_logo() { echo '
        .login h1 a {
            background-image:url("这里添加logo图片网址") !important;
        height: 60px; //修改为图片的高度
        width: 250px; //修改为图标的宽度
        -webkit-background-size: 250px; //修改为图标的宽度
        background-size: 250px; //修改为图标的宽度
        }
    '; } add_action('login_head', 'my_custom_login_logo');

Custom Logo Link

Change the link of the Logo to the homepage link of the website:

//The LOGO link of the custom login page is the home page link add_filter('login_headerurl', create_function(false,"return get_bloginfo('url');"));

Modify the link URL of the Logo

//The custom login interface logo link is any link function custom_loginlogo_url($url) { return 'https://www.wpdaxue.com'; //modify the URL address} add_filter( 'login_headerurl', 'custom_loginlogo_url' );

Customize Logo prompt information (title)

//The LOGO prompt of the custom login page is the website name add_filter('login_headertitle', create_function(false,"return get_bloginfo('name');"));

or defined as any text

//The custom login page logo prompt is any text function custom_loginlogo_desc($url) { return '米国生活Builder Business School'; //Modify text information} add_filter( 'login_headertitle', 'custom_loginlogo_desc' );

Customize login box content

/Add extra information in the login box function custom_login_message() { echo 'Welcome to '.get_bloginfo('name').', please log in to download the resources of this site '; } add_action('login_form', 'custom_login_message');

custom bottom content

//Custom bottom information function custom_html() { echo ' © ' .get_bloginfo(url).' '; } add_action('login_footer', 'custom_html');

custom CSS

You can use the following code to import your own CSS, pay attention to modify the css address in the code, the following calls login_style.css in the theme root directory:

//Add custom CSS function custom_login() { echo '  '; } add_action('login_head', 'custom_login');

With WordPress hooks, a lot of customization can be done, not just the login page.For WordPress theme or plugin developers, mastering the various hooks of WordPress is a necessary skill.

Back to Top