Page 1 of 1

Question on proper syntax for using bloginfo()

Posted: Sat May 09, 2009 10:13 am
by knockeddown
Hi, I'm using wordpress and placing an image on a page with:

Code: Select all

echo "<img src=\"http://www.SITENAME.com/wp-content/them ... GENAME.jpg\" alt=\"IMAGEDESCRIPTION\" />\n";
This works great, but I would really like to use the bloginfo() function so I don't have to type out the entire URL - but I can't figure it out. I'm trying to do something like this:

Code: Select all

echo "<img src=\"bloginfo('template_directory')/images/IMAGENAME.jpg\" alt=\"IMAGEDESCRIPTION\" />\n";
I think I'm screwing up the single and double quotes somehow. Any help on proper syntax is appreciated!

Re: Question on proper syntax for using bloginfo()

Posted: Sat May 09, 2009 10:18 am
by Defiline

Code: Select all

<?php
    
    // ...
    echo '<img src="'.bloginfo('template_directory').'/images/IMAGENAME.jpg" alt="IMAGEDESCRIPTION" />';
    // ...
?>

Re: Question on proper syntax for using bloginfo()

Posted: Sat May 09, 2009 10:50 am
by knockeddown
Hey thanks, but it doesn't quite yet work and when I check the source page it looks like this -

Code: Select all

http://www.SITENAME.com/wp-content/themes/THEMENAME/<img src="images/IMAGENAME.jpg" alt="IMAGEDESCRIPTION" />
It is strangely starting the img tag in between the file. Any thoughts? or I could just stick with my original full path name I guess.

Re: Question on proper syntax for using bloginfo()

Posted: Sat May 09, 2009 11:25 am
by knockeddown
Ok, got it working. My mistake - need to use get_bloginfo() here. So we end up with:

Code: Select all

echo '<img src="'.get_bloginfo('template_directory').'/images/IMAGENAME.jpg" alt="IMAGEDESCRIPTION" />';
Thanks again for the help.