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
1  
Thanks Pieter, its sorted –  Sumit Apr 10 at 14:59

4 Answers 4

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
    
This uses the login message field which could be used for other text and resides OUTSIDE the h1 tags. Ideally you would want this to appear INSIDE the tags so that you could otherwise use CSS to format the text in a unique way and not affect the message field should it be used for whatever reason. –  Madivad Dec 12 at 2:24

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 really depends on what text you want to replace it with.

For example: if you want to replace it with the blog title, then believe it or not, it is VERY simple and can be done through CSS alone.

The blog title already appears in the image, but it's been shifted offscreen by text-indent and all is required is to return it to normal.

.login h1 a {
    text-indent: 0;
    background-image: url('');
    background-size: auto;
    width: auto;
    color: #fff;
    font-size: 1.5em;
}

Setting the URL to '' removes it, in the event you want to totally get rid of the background image. Set colour and size as necessary.

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.