• Resolved Deftwun

    (@deftwun)


    Original post

    I have this issue where I can’t seem to get my image to display when it is in my child themes folder. If I plop it in the root wordpress folder and just point to the file name of the image it works fine.

    so heres a bit of code that I’m dealing with:

    <?php
        $imgpath = get_stylesheet_directory();
        $imgpath = $imgpath."/logo.png";
        echo $imgpath;
    ?>
    
    <div id="header">
        <img width="800px" height = "300px" src="<?php echo $imgpath ?>";/>
    </div><!--  #header -->

    $imagepath resolves to this:
    C:\wamp\www\wordpress/wp-content/themes/TestTheme/logo.png

    the slashes are backwards after the root directory which seems to cause my image to point to an ‘about:blank’ page.

    I’m still pretty new to web programming so I’m sure that I’m ignorant of something going on here.

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Deftwun

    (@deftwun)

    aha!

    bloginfo

    so I used ‘bloginfo(‘stylesheet_directory’) instead and got this as the address:

    //localhost/wordpress/wp-content/themes/TestTheme/logo.png

    Heres the code I used:

    <?php echo bloginfo('stylesheet_directory'); ?>/logo.png
    <img width="800px" height = "300px" src="<?php bloginfo('stylesheet_directory');?>/logo.png";/>

    works like a charm. So I dont know what exactly this is for then (deprecated maybe?). If your trying to do what I was you probably shouldn’t use it though lol.

Viewing 1 replies (of 1 total)
  • The topic ‘trouble with local server and "get_stylesheet_directory"’ is closed to new replies.