How do you add custom logo to entire themes

I would like to add a custom logo to my entire blog network’s dashboard. I went trough a recipe on smashing magazine and got this code:

//hook the administrative header output
add_action('admin_head', 'my_custom_logo');

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

Where do I add it? I think that I should add it in functions.php. But if so I should add the code to every theme in my mutlinetworks.

Read More

Does any one have idea to add it to the entire network?
I should also able to set only for a particular sub and not to entire network If I change my mind in future 🙂

Thank you!

Related posts

Leave a Reply

3 comments

  1. If you want this logo to show up across your network sites regardless of the theme I’d advise you to create a new PHP file inside wp-content/mu-plugins (create the directory if it doesn’t exist) and drop that code inside the new file. You can name your file whatever you like – for example my-network-tweaks.php. That file will be loaded automatically as a plugin on all of the sites.

    And if you’d like to override this image for a particular site you can make that function pluggable. Like this:

    <?php
    //hook the administrative header output
    add_action('admin_head', 'my_custom_logo');
    
    // if override function exists load it up instead
    if(function_exists('override_my_custom_logo')) {
    
        function my_custom_logo() {
            override_my_custom_logo();
        }
    
    // fallback to original function
    } else {
    
        function my_custom_logo() {
            echo '
            <style type="text/css">
                #header-logo { background-image: url('/path/to/images/custom-logo.gif) !important; }
            </style>
            ';
        }
    
    }
    ?>
    

    Note that I’ve changed the image path because we want it to point to a single file for the whole network. Using get_bloginfo('template_directory') would cause it to load the image from the theme directory.

    If you want to override the image for a single site, just use Tom J Nowell’s code renaming the function to override_my_custom_logo

  2. Place this in functions.php and add a file custom-logo.gif ( 32×32 pixels ) in an images subfolder of your theme.

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