Support » Fixing WordPress » Need to use site_url for image src path

  • I am having issues for some reason and I cannot get the any variation of the following code to work to reference an image in my footer.

    <img src="<?php bloginfo('site_url'); ?>/images/4.png" alt="Safety Whistle" />

    <img src="<?php bloginfo('template_directory'); ?>/images/4.png" alt="Safety Whistle" />

    <img src="<?php echo site_url("images/4.png"); ?>

    <img src="<?php bloginfo('template_url'); ?>/images/4.png" alt="Safety Whistle" />

    This is where the image is physically stored:

    however, the Blog/Site URL will change to once the site is live.

    So… what the heck! Can someone please help me understand why my code is NOT working.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Why not just hard code it??
    <img src="")

    Sorry I also have the images stored in an “IMAGES” folder in the template directory as well.

    So I am so very, very confused as to why this is NOT working.

    I am almost BALD!!!!

    What exactly is it you are trying to do?

    Okay… well I guess I am not completely bald yet. The answer was… Drum Roll!

    The content area I was placing the code DID NOT allow for PHP code to be used. It was in the dashboard of the Custom Template an area labeled Footer Content. This Template did NOT allow PHP references in there.

    I put the code string in the footer.php file instead. It works. But now the client cannot change or edit the images. Which bites!

    Hope this helps someone else!

    @josh… because the domain name will change and be moved. So I do not want to have to remember every where I need to change hard-coded urls.

    try this <img src=”<?php bloginfo(‘homeurl’); ?>/images/4.png” alt=”Safety Whistle” />

    or <img src=”<?php bloginfo(‘wpurl’); ?>/images/4.png” alt=”Safety Whistle” />

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Need to use site_url for image src path’ is closed to new replies.