Custom Fields
Re-Envisioned
Support General Can't retrieve data from my group

  • Creator
    Topic
  • #32349
    Resolved info@ceescoenen.nl
    Participant

    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;
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #32362
    Long Nguyen
    Moderator

    Hi Cees,

    You can try to pass the post ID to the helper function rwmb_meta() like this

    function showElement($type, $post_id) {
        $group = rwmb_meta( 'ptm_elements', '', $post_id);
    ...
    }

    Refer to the documentation https://docs.metabox.io/rwmb-meta/

    #32363
    info@ceescoenen.nl
    Participant

    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.

    #32387
    Long Nguyen
    Moderator

    Hi,

    When you call the custom function and pass the type to the group, you need to pass the post ID also. For example

    showElement( 'my-type', 12345 )

    Or you can contact Oxygen support to get the post ID and pass it to the helper function rwmb_meta().

    #32390
    info@ceescoenen.nl
    Participant

    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.

    #32421
    Long Nguyen
    Moderator

    Hi Cees,

    The post ID is written down in the helper function rwmb_meta() documentation as I posted above.
    https://docs.metabox.io/rwmb-meta/

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.