Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add images to a wordpress theme when working on MAMP?

I am new to MAMP and I am developing a theme I designed. However I can't seem to get the images to render. I am using a clear theme I got from starkerstheme.com When adding an image directly to the code I used:

<img src="<?= $theme ?>/images/logo.png"/>

But the image is not showing up, also I tried to add it to the media library and it's still not rendering.

like image 689
Sophie Avatar asked Jan 17 '12 01:01

Sophie


3 Answers

This works for me:

<img src="<?php echo get_bloginfo('template_url') ?>/images/logo.png"/>

See get bloginfo() function for more info.

like image 119
Robert Zelník Avatar answered Nov 03 '22 23:11

Robert Zelník


You can use the following code to add an image. This works for me:

<img src="<?php echo get_template_directory_uri(); ?>/images/filename.png">
like image 22
ismail Avatar answered Nov 03 '22 22:11

ismail


<?php echo get_template_directory_uri(); ?> 

as suggested gets the PARENT theme, which is OK but if you've developed a child theme (as recommended by WordPress people) you need:

<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/Logo.png">
like image 30
demsley Avatar answered Nov 03 '22 22:11

demsley