Skip Navigation

[Gelöst] shortcodes integration to show the theme root

This support ticket is created vor 8 Jahre. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by cathieH vor 8 Jahre.

Assigned support staff: Dat Hoang.

Author
Artikel
#275222
12-01-2015 23-38-07.jpg

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.

#275275

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;
}
#275674

This worked, thank you.