1

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!

1
  • Welcome to WPSE janoChen.. :)
    – t31os
    Dec 23 '10 at 14:03
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)

3
  • 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) 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... Dec 23 '10 at 15:57
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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