Hoping someone can answer this!
I’m using this for my header and it is working:
<img src="<?php echo get_template_directory_uri(); ?>/images/image.jpg">
But when I try to use it in a sidebar text widget it won’t show the image. Any ideas?
Hoping someone can answer this!
I’m using this for my header and it is working:
<img src="<?php echo get_template_directory_uri(); ?>/images/image.jpg">
But when I try to use it in a sidebar text widget it won’t show the image. Any ideas?
You must be logged in to post a comment.
PHP code won’t run inside of a text widget. There are plugins that will let you do that, but this type of thing is strongly discouraged.
Add this code to your functions.php file, or better yet, make it a simple little plugin:
To use it in the admin, add the shortcode
[template_directory_uri]
to your text widget, and the template directory will be output e.g.You can use a php widget, which is a plain text widget adapted to be able to execute php. See WordPress ⺠PHP Code Widget « WordPress Plugins by http://ottodestruct.com
A simple solution would be to upload the image to media, and use the
url
as the src for the image in the text widget.