1

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.

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!

3 Answers 3

2

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
  • As I understand ...I need to copy the code given by Tom and place it in a new file custom_logo_for_entire_site.php under plugins . ANd I need to use replace the image path given in Tom's code using ('/path/to/images/custom-logo.gif') .Where do I need to keep the logo image? Do I need to create a new images folder under the /wpcontent ?
    – user391
    Commented Sep 3, 2010 at 10:50
  • Put the file in wp-content/mu-plugins, not in the regular wp-content/plugins forlder. The image path is totally your choice - you can put the image for example inside wp-content/uploads(main blog uploads folder) and then the path to it will be get_bloginfo('wpurl') . /wp-content/uploads/custom-logo.gif' Commented Sep 3, 2010 at 21:52
1

You might check out the White Label CMS plugin to automate this for you.

2
  • That plugin looks great. Wish I'd known about it years ago!
    – Doug
    Commented Sep 2, 2010 at 15:42
  • We can add logo and use the plugin to white label.But I would like to know that how do I use the additional functions like adding widgets to dash board,changing default gravator ,adding and removing default profile fields etc using functions.php .We may have all these functionalities with different plugins. But I came to know that there are some tricks to add the functionalities using functions.php .So that we can also save our site from high page loading speed caused by plugins. So could you help me If I can add this kind codes using functions.php to all the themes ?
    – user391
    Commented Sep 2, 2010 at 16:38
1

Place this in functions.php and add a file custom-logo.gif ( 32x32 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>
';
}

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.