Skip Navigation

[Resolved] Can't retrieve custom post field on Ocean wp child theme

This support ticket is created 2 years, 11 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
- 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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by xiaolinW 2 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#2052639

Hi, I created the Ocean wp child theme and I'm creating a custom template for a custom post, everything seems working, the only thing I'm stuck in is retrieving current post fields/custom fields. I tried echo get_post_meta( get_the_ID(), "wpcf-key", true ); or even types_render_field( "key", array( ) ) , but I can't make it work... Am I missing something?

#2052853

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

The first thing I would check is whether or not your code is executing within the WordPress loop. And the best way to confirm this is by printing the 'get_the_ID()' value alone. If you don't get the current post's ID, it would explain why 'get_post_meta' and 'types_render_field' are not returning the custom field values.

Please also make sure that the custom field slug or key being used is correct and matches what is used in the custom field group settings.

Lastly, also make sure that some value is added in that custom field, in the post that you're testing your code with.

I hope this helps and please let me know how it goes.

regards,
Waqar

#2055335

My issue is resolved now. Thank you!

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