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?
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
My issue is resolved now. Thank you!