• I have a wordpress site installed in a WAMP Server localhost environment on my machine.

    Right now, my links to images are hard-coded and work fine.

    I went to a wordpress group meeting tonight, and someone there showed me how to use this php function instead of doing all the hard-coding.

    <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/aternus.png" alt="" width="" height="" />

    So, I plugged it in, made the appropriate path changes, tried every path configuration I could, and it won’t work—no image on the page.

    Somehow, it cannot find the path to my image folder. I’ve tried it several times, being careful to check every single character in the string, alas, no image on the page.

    Can someone please tell me what—if anything—I’m doin’ wrong?

    Thanks so much.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Are you working on a theme? If so, what kind of HTML are you getting on your page?

    Thread Starter adhdcelt

    (@adhdcelt)

    No, not working on a theme; I’m working on a website. I’m using the wordpress twentyten theme with a child theme.

    I don’t get html on the page. When I replace the hard code in the string that needs to be replaced, with the php function in this post, update the page, then view the page, the image just doesn’t show up. All I see is the alt=”xxx” description. The page looks fine, the image just doesn’t show up.

    No, not working on a theme; I’m working on a website.

    Where exactly are you using this code? <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/aternus.png" alt="" width="" height="" /> ?

    Some reference material (contains the example code you used above): http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

    Thread Starter adhdcelt

    (@adhdcelt)

    I’m using this code in a page in my wordpress site where I want the image to go just like it reads in the example except for the directory path code that is specific to my site.

    In other words, the code in the page that points to my image folder looks like this:
    <img src="http://localhost/wordpress/wp-content/imagefolder1/imagefolder2/imagefolder3/the-image-itself.png" alt="xxxxxxxxx" width="xxxxxxx" height="xxxxx" />

    The above code works just fine and loads the image, no problem.

    However, this code does not work when I replace the hard-coded directory path with the php function:
    <img src="<?php echo get_stylesheet_directory_uri(); ?>/imagefolder1/imagefolder2/imagefolder3/the-image-itself.png" alt="xxxxxxxxx" width="xxxxxxx" height="xxxxx" />

    Same code as the hard code that works, except for the php function. Everything I look at says this php function code should work. The examples are exactly the same as what I’m doing except for the specific directory path for my image files. However, I must be doin’ something wrong, here.

    http://localhost/wordpress/wp-content/imagefolder1/imagefolder2/imagefolder3/the-image-itself.png

    That path doesn’t appear to include a stylesheet directory. I think the stylesheet directory might be interpreted as the path to the active theme directory.

    Your image folders in that path appear to be located one level above, in /wp-content/imagefolder/ – rather than – /wp-content/themes/themename/imagefolder

    Function Reference/get stylesheet directory

    “Retrieve stylesheet directory Path for the current theme/child theme. “

    Just a guess, mind you.

    Thread Starter adhdcelt

    (@adhdcelt)

    Yes, my images are in the wp-content/xxxxximages folder; however, as I understand it, “theme images” go in the themes/themename/images folder, and content images go in the wp-content/images folder.

    The code the guy showed me last night pointed to his image folder in the wp-content folder.

    Anyway, I just created an image folder in the child theme folder, put the image in it, and used the themes/themename/image folder path, and it still didn’t work. I even tried it removing the “uri() designation from the php function: nothing.

    It’s got to be pilot error somewhere, here; I just don’t know where.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘won't work.’ is closed to new replies.