Search code examples
phphtmlwordpressgenesis

Image source path changing on different pages


I'm using Genesis and I have a functions.php that I have inserted images there using hooks to the footer.

I've used a widget to insert an image to the header.

The images are displayed correctly when viewed in the homepage, but when I switch a page, the images are not displayed.

Further investigation concludes that wordpress is seeking the file with a wrong path source.

That's the path source in the homepage - wp-content\themes\childTheme-Almog\images\linkedin.png

And wordpress is looking for it as it should.

However, on another page, called 'X', wordpress is looking for the same image as follows: \wordpress\x\wp-content\themes\childTheme-Almog\images\linkedin.png

As you can tell, it adds to the path the page name as a folder, which it shouldn't do, because the image is not there.

Is there a way to make wordpress look for the image like it does on the homepage?

Here's how my images are implemented in my functions.php:

<div class="d_footer">
        <ul id="list_left">
            <li class="foot" id="ft_text1"><img src="wp-content\themes\childTheme-Almog\images\phone.png" alt="phone">
                <span style="color: #969697">|</span><span style="margin-left:30px;"></span><img src="wp-content\themes\childTheme-Almog\images\envelope.png" alt="envelope"></li>
            <li class="foot" id="ft_text2"></li>

        </ul>
    <ul class="foot" id="list_right">
        <li id="ft_text3"><img src="\wp-content\themes\childTheme-Almog\images\linkedin.png" alt="linkedin" align="left">Almog's linkedin profile</li>
        <li id="ft_text4"></li>
    </ul>
</div>

Solution

  • You really should be using Wordpress' get_stylesheet_directory_uri variable to alleviate problems with paths like this.