Skip Navigation

[Resolved] Custom Field inside a PHP function

This support ticket is created 5 years, 8 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1223019

Hi,

I made a page template, inside the page template is a slider

<?php if ( function_exists( 'soliloquy' ) ) { soliloquy( '470' ); } ?>

Instead off 470 I want the fill this field dynamicly with a Custom Field:

<?php echo do_shortcode('[types field="id-slider"]'); ?>

How can I mix these two together?

#1223112

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

Types custom fields are just WordPress post meta, so can be retrieved using standard functions like get_post_meta (https://developer.wordpress.org/reference/functions/get_post_meta/).

You just need to be aware that the keys are prefixed with 'wpcf-'.

So you could combine the above like so:

$slide_id = get_post_meta( get_the_ID(), 'wpcf-id-slider', true );
if ( function_exists( 'soliloquy' ) ) { soliloquy( $slide_id ); }