What is wrong with my PHP code?

I have been seriously been looking at this forever! I'm going out of my mind And can't figure out why my images are not displaying in my custom made footer.

I have firefox with firebug and it is simply saying that the url is failing to load. so I copy and pasted a url to an image that is currently working and is being shown via the background property in CSS just fine. (thats the top one that says dakota jones). copy and pasting the exact img src proves it still not to work.

my folder is images. My functions.php is right outside. the hierarchy is correct. what the heck?? The testing text in the p tags work just fine. uhuhuhu

Somebody help me! I'm using wp and genesis theme.

add_action('genesis_before_footer', 'include_sponsors');
function include_sponsors() { ?>
    <div class="sponsors">
    <p>This is testing text</p>
    <img src="images/dakotajonesheader3.jpg" alt="Smiley face" height="42" width="42" />
    <img src="images/tfobw.png" />
    <img src="images/basskingbw.png" />
    <img src="images/bighawgbw.png" />
    <img src="images/kbw.png" />
    <img src="images/mccoybw.png" />
    <img src="images/nfcbwpng" />
    <img src="images/rayjusbw.png" />
    <img src="images/rrbw.png" />
    </div>  
<?php }

Answers


Use WordPress' inbuilt function:

<?php
bloginfo('template_directory'); ?>/images/dakotajonesheader3.jpg
?>

.. which will reference /wp-content/themes/your-theme/images/dakotajonesheader3.jpg


Wordpress dynamically rewrites URLs, so the URL you use to access a page is not the same as the path to the scripts that are running on the server. So you might request your page with example.com/Home. But your images are not stored in example.com/Home/images, which is where you're telling your browser to look. They're stored in example.com/wordpress/wp-content/themes/your_theme/images. So you have to give the absolute path to the images to the browser in your <img> tags.


Carson is correct, and you can use absolute paths to your images. Alternatively, if you want to avoid using absolute paths, you can call your images using bloginfo('template_directory');

For example:

<img src="<?php bloginfo('template_directory'); ?>/images/dakotajonesheader3.jpg" alt="Smiley face" height="42" width="42" />

Need Your Help

Level Order Traversal w/ Binary Trees using Java and Recursion

java recursion binary-tree

I am having problems with the level order traversal of my binary tree whilst using recursion. I am inputing the following values: 50,60,70,30,20,10