WordPress.org

Ready to get started?Download WordPress

Forums

Need to use site_url for image src path (7 posts)

  1. deedles916
    Member
    Posted 2 years ago #

    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:

    http://dmddesign.com/jennatime/images/4.png

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

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

  2. Why not just hard code it??
    <img src="http://dmddesign.com/jennatime/images/4.png")

  3. deedles916
    Member
    Posted 2 years ago #

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

    http://dmddesign.com/jennatime/wp-content/themes/DMDCustom/images/4.png

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

    I am almost BALD!!!!

  4. What exactly is it you are trying to do?

  5. deedles916
    Member
    Posted 2 years ago #

    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!

  6. deedles916
    Member
    Posted 2 years ago #

    @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.

  7. Elan Technosys
    Member
    Posted 2 years ago #

    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" />

Topic Closed

This topic has been closed to new replies.

About this Topic