Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Fivvle Divvle
Fivvle Divvle
928 Points

Logo in header.php loading in index.php but not page.php

Hi,

Have created a header.php and have a logo in navbar, however, something funny is happening because the logo loads in index.php but not in static page templates like page.php. This is code i am using for logo

 <a href="<?php bloginfo('url'); ?>">
     <img src="wp-content/themes/playground-theme/image/logobro.png" />
 </a>

1 Answer

Just a hunch, but try changing the image URL to an absolute address, like so:

<a href="<?php bloginfo('url'); ?>">
     <img src="/wp-content/themes/playground-theme/image/logobro.png" />
 </a>

Notice the leading slash /

If this does not work, one way to troubleshoot this is to right click on the broken image and view the properties and view the URL that it is trying to load. Or view the source code and see the URL there.

Fivvle Divvle
Fivvle Divvle
928 Points

Hey Jesse, Thanks for your steadfast reply ! :)

I've just tried putting a " / " before wp-content but still to no success.

From checking out the image URL though, i have been able to see that it's because wordpress will add a extra directory for the page that im on.

For e.g

Am on "contact" page, the link is then altered to

contact/wp-content/themes/........etc

So i guess the question now is how to I stop wordpress from adding the the page name into the link ?