wordpress get_template_directory wordpress get_template_directory wordpress wordpress

wordpress get_template_directory


I used this code instead and it worked

<img src="<?php bloginfo( 'template_directory' ); ?>/images/bg.png"></img>


get_template_directory() returns the directory, but it doesn't echo it.. so if you use it with echo it will work

<img src="<?php echo get_template_directory(); ?>/images/bg.png"></img>

but I will suggest to use get_template_directory_uri() instead, because above will not be portable ( windows use backward slashes as separator )

<img src="<?php echo get_template_directory_uri(); ?>/images/bg.png"></img>


that's odd... Can you try get_stylesheet_directory() instead and see what that returns?