Page 1 of 1

PHP syntax help needed

Posted: Thu Jan 19, 2012 1:27 pm
by bgbs
Here is the statement I'm having trouble with

Code: Select all

echo '<img src="'. bloginfo('template_directory') .'/images/image.png" title="" alt="" />';
In html source it outputs it like this:

Code: Select all

http://site.com/wp-content/themes/mytheme 
<img alt="" title="" src="/images/image.png">
For some reason it divided the path to image into two parts.
Any ideas what I'm doing wrong?

Re: PHP syntax help needed

Posted: Thu Jan 19, 2012 3:33 pm
by StathisG
As you can see here, bloginfo echoes the information, where get_bloginfo returns it as a variable. So, your code should be:

Code: Select all

echo '<img src="'. get_bloginfo('template_directory') .'/images/image.png" title="" alt="" />';

Re: PHP syntax help needed

Posted: Thu Jan 19, 2012 5:57 pm
by bgbs
Oh, you're good.
Thanks man!

Re: PHP syntax help needed

Posted: Thu Jan 19, 2012 6:52 pm
by StathisG
You're welcome :)