Skip Navigation

[Résolu] How to execute a shortcode within a custom field type

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created Il y a 10 années. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 réponses, has 2 voix.

Last updated by jamesG-3 Il y a 10 années.

Assisted by: Luo Yang.

Auteur
Publications
#208642

I would like to execute a shortcode for responsive vimeo embeds in a custom field type. Due to wordpress stripping shortcodes outside of the body however I am unable. Does anybody know how to make this happen?

Thanks so much!

#208727

Hi jamesG-3,

I suggest you create another shortcode for it, for example your custom field is using slug my-vimeo. created with Types, in database it's meta-key is wpcf-my-vimeo,
You can try this:
1) add codes in your theme/functions.php:

function my_vimeo_func( $atts ) {
$my_vimeo = get_post_meta(get_the_ID(), 'wpcf-my-vimeo', true);
return do_shortcode($my_vimeo); 
     return "foo = {$foo}";
}
add_shortcode( 'my-vimeo', 'my_vimeo_func' );

2) use shortcode [my-vimeo] in your content

More help:
http://codex.wordpress.org/Function_Reference/add_shortcode

#208812

Thank you for the response. I am actually trying to use an existing shortcode that came with the skeleton theme

[vimeo id="68293434" responsive="true" center="false"] 

Because it does a fantastic job of resizing the videos in a responsive manner on tablets etc. In trying the method above I was unable to subsequently replicate the responsive video sizing.

My hope is to place this shortcode within a view and be able to have that show the video if that makes sense?

Thanks again!

#209073

I suggest try create a custom field vimeo-id to store 68293434 values
Go to Views -> Settings and simply add them under the section Third-party shortcode arguments:
add "vimeo"
Then use below shortocde within your view content
[vimeo id='[types field="app-id"][/types]' responsive="true" center="false"]

More help:
Shortcodes within Shortcodes – Control Any Shortcode with Types Fields
https://toolset.com/documentation/user-guides/shortcodes-within-shortcodes/

#209162

That worked a treat, thanks so much!

Le forum ‘Types Community Support’ est fermé à de nouveaux sujets et réponses.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.