WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my new worpress install, I have code that reads

<img src="<?php get_stylesheet_directory_uri(); ?>/images/logo.jpg" />

This code worked, untill I started using a subdomain (went from example.com/dev to dev.example.com) and changed these urls in my general settings.

Now the get_stylesheet_directory_uri() does not output anything:

<img src="/images/logo.jpg" />

I swapped it with the following: bloginfo(stylesheet_directory) which seems to work fine, but I am used to get_stylesheet_directory_uri() and it seems like this is the reccomended approach.

share|improve this question
up vote 5 down vote accepted

That would be because get_stylesheet_directory_uri only returns a value. If you want to echo it to to the screen you have to include echo or print.

<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/logo.jpg" />

bloginfo works fine as well, but when you do stylesheet_directory it's just a wrapper for get_stylesheet_directory_uri

function get_bloginfo( $show = '', $filter = 'raw' ) {

    switch( $show ) {
        // snip snip

        case 'stylesheet_directory':
            $output = get_stylesheet_directory_uri();
        // snip snip
    $url = true;
    if (strpos($show, 'url') === false &&
        strpos($show, 'directory') === false &&
        strpos($show, 'home') === false)
        $url = false;

    if ( 'display' == $filter ) {
        if ( $url )
            $output = apply_filters('bloginfo_url', $output, $show);
            $output = apply_filters('bloginfo', $output, $show);

    return $output;
share|improve this answer
well i'll be. I thought I stopped making that mistake a long time ago ;-). Weird though, I could swear it worked for a time before that domain switch – Zach Lysobey Dec 2 '11 at 19:13

Your Answer


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.