0

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

4

3 回答 3

2

你应该试试:

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>.';

在此处阅读更多信息http://codex.wordpress.org/Function_Reference/get_bloginfo

于 2012-09-12T08:44:12.063 回答
1

你要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>.';

有关文档,请参阅http://codex.wordpress.org/Function_Reference/get_template_directory_uri

于 2012-09-12T08:41:19.723 回答
1

这里有不同的功能供您参考..

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.

对于您的用例尝试:

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>.';

文档:http ://codex.wordpress.org/Function_Reference/get_template_directory_uri

还可以通过http://codex.wordpress.org/Function_Reference/ {function_name_here}访问其他功能的文档

于 2012-09-12T08:44:03.027 回答