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 would like to know if there's a way of giving an option (in the admin panel) to the user to change the text of the site title for an uploaded logo image.

So basically it would go like this:

If there's an uploaded image for the site title, don't show the text otherwise just display the site title text.

Does anyone know any tutorial or how to do it?

Thanks in advance!

share|improve this question
    
Welcome to WPSE janoChen.. :) –  t31os Dec 23 '10 at 14:03

2 Answers 2

I figured out how:

<?php

    // Theme Options
    require_once(TEMPLATEPATH . '/functions/admin-menu.php');

    add_action( 'wp_head', 'theme_options');

    function theme_options() {
        // Initiate Theme Options
        $options = get_option('plugin_options');

        // If logo image was uploaded then remove text from site title
        if ($options['logo'] != NULL)
          $remove_text = '-9999px';
        else
          $remove_text = 0;

        ?><style>
        body {
            background-color: <?php echo $options['color_scheme']; ?>
        }

        #header h1 a {
            background: url(<?php echo $options['logo']; ?>) no-repeat scroll 0 0;
            text-indent: <?php echo $remove_text; ?>;
        }
        </style><?php

    }

(The code works but please let me know if there's a cleaner or easier way of doing this)

share|improve this answer
    
why make the logo a background image? you should put it in a <img> tag for accessibility reasons (then you won't need text-indent either) –  onetrickpony Dec 23 '10 at 12:24
    
@Ambitious Amoeba not sure but every professional website does that. I guess it is for the following reasons: 1)Better SEO 2)I can make a link hover with just css 3)If stylesheets are disabled the page title will look the same as the other elements. –  janoChen Dec 23 '10 at 13:56
    
I thought it's the other way around :) I don't see the logo as part of site design, but of the content. Maybe I'm wrong about this... –  onetrickpony Dec 23 '10 at 15:57

You can do that using a theme options page - here is a tutorial Once you've added an options page, you add in it a field for site logo.

in the theme code you check if this field was assigned a value, and assign the tite accordingly

share|improve this answer

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.