Wordpress template directory PHP code outside of echo -


i hope silly simple thing. i'm trying add quick conditional code, showing image instead of text choice. i'll post code.

<?php if(get_field('our-rating') == "4 stars") { echo '<img src="' . bloginfo("template_directory") . '/images/4-stars.png">'; } ?> 

my problem code producing html output:

www.site.com/wp-content/themes/dn4l<img src="/images/4-stars.png"> 

am doing wrong? have sworn i've done dozen times before. guys!

bloginfo outputs, get_bloginfo returns. what's happening here template_directory being output while you're building string, before output string.

use get_bloginfo instead:

https://codex.wordpress.org/function_reference/get_bloginfo


Popular posts from this blog