Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I wanted to replace the wordpress logo which is displayed on login screen with some custom text.

Here is the code what I tried so far:

function my_custom_logo() {
echo '<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/images/wp-logo.png) !important; }';
}
add_action('admin_head', 'my_custom_logo');

It can replace the logo but what should I need to replace it with some text? Any suggestions to make it work?

share|improve this question
    
Have you problem been solved yet? –  Pieter Goosen Apr 9 at 19:27
1  
Thanks Pieter, its sorted –  Sumit Apr 10 at 14:59

3 Answers 3

up vote 1 down vote accepted

You will first need to remove the wordpress logo from the login screen. The wordpress logo is added by css, so you will need to change the css and hook that to the login_enqueue_scripts action hook

function my_login_logo() { ?>
    <style type="text/css">
        body.login div#login h1 a {
            background-image: none;
            background-size: 0 0;
            height: 0;
            margin: 0 auto 0;
            width: 0;
}
        }
    </style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );

Next you can add your custom message

function custom_login_message() {
$message = "Your custom message goes here";
return $message;
}
add_filter('login_message', 'custom_login_message');

You can go and have a look at the codex for additional hooks and filters for the login form

share|improve this answer

The logo is written into the CSS and the link text and target are filterable:

    105         /**
    106          * Filter link URL of the header logo above login form.
    107          *
    108          * @since 2.1.0
    109          *
    110          * @param string $login_header_url Login header logo URL.
    111          */
    112         $login_header_url = apply_filters( 'login_headerurl', $login_header_url );
    113         /**
    114          * Filter the title attribute of the header logo above login form.
    115          *
    116          * @since 2.1.0
    117          *
    118          * @param string $login_header_title Login header logo title attribute.
    119          */
    120         $login_header_title = apply_filters( 'login_headertitle', $login_header_title );

https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-login.php#L89

For example:

function alter_login_headerurl() {
  return 'http://example.com';
}
add_action('login_headerurl','alter_login_headerurl');

function alter_login_headertitle() {
  return 'Yay';
}
add_action('login_headertitle','alter_login_headertitle');

To alter the image enqueue a login stylesheet and override the background image on .login h1 a.

share|improve this answer

It's simple

function my_custom_logo() {
echo '<script>jQuery("#header-logo").html("<h1>My Text Logo</h1>")</script>';
}
add_action('admin_head', 'my_custom_logo');
share|improve this answer
2  
Please givge an explanation to why this should work –  Pieter Goosen Apr 8 at 13:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.