I want to use the <?php bloginfo('stylesheet_directory'); ?> inside my wordpress loop to reference an image but unsure how to do this. My image code is as follows:
<?php
if (is_category('Events')) {
echo '<img src="http://localhost/mmj/wp-content/themes/child-theme/img/live-banner.jpg" class="live-holder-img" />';
} else if (is_category('News')) {
echo '<img src="http://localhost/mmj/wp-content/themes/child-theme/img/live-banner.jpg" class="live-holder-img" />';
} else {
echo '<img src="" class="default" />';
} ?>
I would rather replace http://localhost/mmj/wp-content/themes/child-theme with <?php bloginfo('stylesheet_directory'); ?> but Im aware that I cant include <?php inside <?php so I was wondering how I could do this?
You can use like this :
Full code :
In shortly,
I’m using
get_bloginfo()instead ofbloginfo()for getting stylesheet directory, not printing out. And then using it like this :