John
John

Reputation: 627

Code outputting html instead of an image?

Here is the code that I am referring to:

<?php if ( is_archive() ) { echo '<img src="'.bloginfo('template_url').'/images/test.png" />'; }?>

This is what the code outputs: http://site.com/wp-content/themes/themename

I'd like it to output the actual image in the code. What part of this did I overlook?

Upvotes: 0

Views: 107

Answers (2)

Adriaan
Adriaan

Reputation: 378

Have you tried this:

$template_url = get_bloginfo('template_url');

<?php if ( is_archive() ) { echo '<img src="'.$template_url.'/images/test.png" />'; } ?>

Upvotes: 0

NT_
NT_

Reputation: 2246

bloginfo() doesn't output the string. It echo's it directly to output stream. So, the code should be:

<?php if ( is_archive() ) { ?>
   <img src="<?php bloginfo('template_url'); ?>/images/test.png" />'; 
<?php  }  ?>

Or else, you can use get_bloginfo() :

<?php if ( is_archive() ) { echo '<img src="'.get_bloginfo('template_url').'/images/test.png" />'; }?>

Upvotes: 1

Related Questions