0

I have just upgraded to wordpress 4.5 and now my custom logo for the admin doesn't work, the theme which I built uses the following in the theme functions.php:

/* change admin logo */
function my_login_logo() { ?>
<style type="text/css">
    .login h1 a {
        background-image: url(<?php echo get_field('logo','options'); ?>);
        background-position: center center;
        background-repeat: no-repeat;
        background-size: cover;
        width: 320px !important;
        height: 99px !important;
        margin-bottom: 20px !important;
    }

    .login form {
        margin-top: 0px;
    }
</style>
<?php }

add_action( 'login_enqueue_scripts', 'my_login_logo' );

I cannot find a work around for this, can anyone help?

1
  • If I understand correctly, you're recreating options and theme mods by using ACF to add fields to a post called 'options' which you're then calling. You should use the customizer, theme mods, or options instead, it would be simpler, less fragile
    – Tom J Nowell
    Apr 12, 2016 at 21:03

4 Answers 4

1

I think you have the logo called from the Theme Options try updating your Theme Options alternatively you have many plugins that can help you achieve that. Like:
https://wordpress.org/plugins/add-logo-to-admin/

You can always refer to the Wordpress Codes

https://codex.wordpress.org/Customizing_the_Login_Form

8
  • yes I am using ACF for non-technical users to be able to change the logo easily, and it was working great but then I upgraded to wordpress 4.5 however as WiTon Nope pointed out here: codex.wordpress.org/Customizing_the_Login_Form under 'Change the Login Logo' this is what I have done but it no longer works, its not a ACF issue because I tried just linking to the theme logo. Apr 12, 2016 at 21:24
  • 2
    I'm not sure but sounds the login css is calling both logos the default one and the custom, try adding !important to your function css but try adding the direct logo link as troubleshoot to check it it works then ACF. Let me know if it works or not.
    – WiTon Nope
    Apr 12, 2016 at 21:32
  • Most welcome, happy to hear it's fixed.
    – WiTon Nope
    Apr 12, 2016 at 21:41
  • WiThorpe, I can't it says I need 15 reputation :( Apr 12, 2016 at 22:14
  • Why do you have to add !important all of a sudden, :/ annoying
    – nsilva
    Apr 14, 2016 at 10:50
0

Add !important; to EVERYTHING and that should solve your problem. You don't have your first 4 background items as !important; so they are being overridden. This is why it doesn't work anymore.

0

You might try changing the class login to an id login. Replace .login h1 a {...} with #login h1 a {...}.

0

I just added the id (#login h1 a) to the function and that worked fine.

function my_login_logo() { ?>
    <style type="text/css">
        #login h1 a, .login h1 a {
            background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/login-logo_320px.png);
            padding-bottom: 30px;background-size:160px 160px;width:160px;height:160px;
        }
        .login form {
            background: #f1f1f1 none repeat scroll 0 0;
            border: 1px solid rgba(14, 118, 188, 0.5);
            box-shadow: 0 0 0 rgba(0, 0, 0, 0.13);
        }
    </style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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