Reputation: 11
I have the following line in some code I am trying to modify to include an image from my theme directory.
protected $_branding = 'Site Design by <a href="http://www.mysite.com">MySite</a>.';
So, what I want is:
protected $_branding = 'Site Design by <a href="http://www.mysite.com"><img src="(((My ThemeFolder)))/images/myimage.png" style="vertical-align:text-bottom;"/>MySite</a>.';
What is returned seems to output exactly what is inside the parent quotes. So, I am assuming this is some kind of string. So, how do I make it include a PHP variable to get my theme folder without having to hard code it?
Thank you
Upvotes: 0
Views: 101
Reputation: 4911
Here are different functions for your reference..
get_template_directory(): Returns the absolute template directory path.
get_template_directory_uri(): Returns the template directory URI.
get_stylesheet_directory(): Returns the absolute stylesheet directory path.
get_stylesheet_directory_uri(): Returns the stylesheet directory URI.
for your use-case try:
protected $_branding = 'Site Design by <a href="http://www.google.com"><img src="' . get_template_directory_uri() . '/images/myimage.png" style="vertical-align:text-bottom;"/>MySite</a>.';
docs: http://codex.wordpress.org/Function_Reference/get_template_directory_uri
also access docs for other functions by http://codex.wordpress.org/Function_Reference/{function_name_here}
Upvotes: 1
Reputation: 173
You should try:
protected $_branding = 'Site Design by <a href="http://www.mysite.com"><img src="'.get_bloginfo('template_directory').'/images/myimage.png" style="vertical-align:text-bottom;"/>MySite</a>.';
Read more here http://codex.wordpress.org/Function_Reference/get_bloginfo
Upvotes: 2
Reputation: 6185
You want get_template_directory_uri()
protected $_branding = 'Site Design by <a href="http://www.mysite.com"><img src="' . get_template_directory_uri() . '/images/myimage.png" style="vertical-align:text-bottom;"/>MySite</a>.';
See http://codex.wordpress.org/Function_Reference/get_template_directory_uri for the documentation.
Upvotes: 1