Can't retrieve data from my group

Support General Can't retrieve data from my groupResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32349
    info@ceescoenen.nl[email protected]
    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;
    }

    #32362
    Long NguyenLong 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[email protected]
    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 NguyenLong 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[email protected]
    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 NguyenLong 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 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.