Meta Box
Support › General › Can't retrieve data from my groupResolved
I have a field group (ptm_elements) with subfields (not clonable).
The function stops because $group = empty but it isn't. What is wrong?
function showElement($type) { $group = rwmb_meta( 'ptm_elements'); if ( empty( $group ) ) { return ''; } $output = ''; $output = $group[$type] ?? ''; return $output; }
Hi Cees,
You can try to pass the post ID to the helper function rwmb_meta() like this
rwmb_meta()
function showElement($type, $post_id) { $group = rwmb_meta( 'ptm_elements', '', $post_id); ... }
Refer to the documentation https://docs.metabox.io/rwmb-meta/
Hi Long,
I don't understand which post_id U have to use.
The function is placed on an element of a page (in Oxygen) and decide of it is hide or not.
Hi,
When you call the custom function and pass the type to the group, you need to pass the post ID also. For example
type
showElement( 'my-type', 12345 )
Or you can contact Oxygen support to get the post ID and pass it to the helper function rwmb_meta().
Please for me: why I the post-id not in the documentation here: https://docs.metabox.io/extensions/meta-box-group/
Sometimes it cost me a lot of time to figure out how it works.
The post ID is written down in the helper function rwmb_meta() documentation as I posted above. https://docs.metabox.io/rwmb-meta/