Skip Navigation

[Resolved] Pull Custom Field as PHP Shortcode and add it to php file

This support ticket is created 5 years, 9 months ago. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by terryR 5 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1233692
Snip-2.PNG
Snip-1.PNG

Hello,
I would like to ask you for advice if there is way to wrap a custom field into a php shortcode and put it on a separate php file to be pulled from there.
Please refer to the attached images for better understanding of my situation there.
I appreciate your help. Thank you.

Best regards.

What is the link to your site?
hidden link

#1233754

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - what is the reason you want to wrap the custom field using shortcode and featch it using the PHP API?

Types support PHP API function types_render_field() using which you can fetch the post custom field.

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/
=> https://toolset.com/documentation/customizing-sites-using-php/creating-templates-single-custom-posts/#creating-template-parts-with-your-custom-fields-and-design
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#how-to-use-this-field-with-7

#1233758

Hello, thanks for fast answer.
Yes, I want to integrate Toolset custom field to be displayed into another Plugin ( which is the slider from this page - hidden link ) .

So for example I need to try and insert this type of code into the plugin's php file ?

<?php echo(types_render_field( 'media-source', array( 'arg1' => 'val1', 'arg2' => 'val2' ) )); ?>

Please advice me if I am correct here. Thank you.

#1233759

Thank you so much. I managed to make it work!