I am trying to: have a page show images from the theme folder, so that its not hardcoded to the media library. I'd like it to refer to: hidden link
I have this code in my Views Content Template:
[wpv-if url="wpcf-fb-url" evaluate="!empty($url)" condition="true"]<li class="icon-facebook-t">
<a href="[types field="fb-url" output='raw'][/types]" target="_blank"><img src="[themeroot]/images/social-facebook.png"></a>
</li>[/wpv-if]
[wpv-if url="wpcf-fb-url" evaluate="!empty($url)" condition="false"]<li class="icon-facebook-f">
<img src="[themeroot]/images/social-facebook-g.png"></li>[/wpv-if]
and it's this section [themeroot] that I'm trying to get to work.
I've created this in my functions.php and added the shortcode into the views settings as a third party shortcode so that Views is aware of it.
add_shortcode( '', 'themeroot' );
function themeroot() {
$themerooturl = get_theme_root();
return $themerooturl;
}
However it isn't working.
I visited this URL: hidden link
I expected to see: a linked image for a facebook icon.
Instead, I got: broken image icon.
What am I doing wrong? Is my PHP code wrong or have it I tried to implement it wrong within the Views Content Template?
Thank you.
Cathie.
You are missing the parameter $tag. See here: http://codex.wordpress.org/Function_Reference/add_shortcode
The correct code should be:
add_shortcode( 'themeroot', 'themeroot' );
function themeroot() {
$themerooturl = get_theme_root();
return $themerooturl;
}