Support » Fixing WordPress » custom admin logo problem

Viewing 6 replies - 1 through 6 (of 6 total)
  • View source and see what’s been churned out.

    That’ll tell you what your code is outputting and where it hopes to find the image. Then see if your image is in that place.

    If everything’s as it should be then check the css . The default position (since you haven’t specified it) is top left

    I use the ‘login_head’ hook which has worked pretty well in the past. Just make sure the url you supply is valid and pointing at your custom logo.

    You can additionally change where the logo links to and its title attribute quite easily.

    function custom_login_logo() {
    	$custom_logo = 'add your logo image path here'; ?>
    	<style type="text/css">
    		h1 a { background-image:url('<?php echo $custom_logo; ?>') !important; }
    	// Optionally change where the logo links to and the title attribute
    	// You will need to define 'custom_wp_login_url', 'custom_wp_login_title'
    	// callback functions yourself to make this work
    	add_filter('login_headerurl', 'custom_wp_login_url');		// Add link to home page, rather than
    	add_filter('login_headertitle', 'custom_wp_login_title');	// Change the title attribute
    add_action('login_head', 'custom_login_logo');


    @richarduk: I checked the source and it showed me where it was looking for the image; I’m using a child theme and it was looking for it in the parent theme. I added the image there but it still doesn’t show up. Since I’m adding this to my functions.php file what css do I need look at to make any corrections?

    @dgwyer: I tried your code and made the changes you indicated but am a bit confused. Part of the code is above the <?php tag. When I put it above that tag in my file it prints an error code above the header on my website. When I put it below the tag it gives me an error code to the line that the code is on. I’ve tried using all the code you listed, just the top half, just the bottom half, put it above the php tag, below the tag, and other combinations but keep getting an error code.

    Thank you both for your help; I worked on this one part for about 10 hrs yesterday and already 4 hrs today. Maybe I’m just not seeing something correctly by now. In the past I’ve used a plugin to accomplish this but I am working to reduce the number of plugins I use for the sites I develop.

    To fetch an image from a child theme change template_directory to stylesheet_directory

    You don’t need to change the code snippet I posted at all. Just make sure it goes in your themes (or child themes preferably) functions.php file at the bottom somewhere before the closing PHP tag.

    Some times in PHP it is easier to close the PHP tag to output some HTML in a PHP function before re-openening the PHP tag. It’s just a commonly used approach.

    If you add the code and change the URL to a valid one (i.e. your logo) it should work fine.



    @dgwyer ah ha moment! the code does work – for another task on my list that I was wanted to accomplish. I logged out of the dashboard so I could log in as a different user and voila the login image was my logo.

    What I was trying to change was the logo to the left of the site title in the admin area. Which I just got changed. I just kept moving the code and rewriting it and finally ended up moving the “add action” line to the top of the function I’ve been trying to create. Once I did that it worked!

    Here’s what it looks like now:

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

    Thank you both for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘custom admin logo problem’ is closed to new replies.