File advanced rwmb_meta helper, array error

Support General File advanced rwmb_meta helper, array error

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30547
    kapitanpejsek@gmail.com[email protected]
    Participant

    Hello,
    when I use rwmb_meta helper to get a link for file download into Oxygen repeater. I need to get just one file.

    <?php
    $files = rwmb_meta( 'cf-den-1-ustanoveni', array( 'limit' => 1 ) );
    $file = reset( $files );
    ?>
    <a href="<?php echo $file['url']; ?>">Ustanovení</a>
    

    I get the link on the frontend just fine, but backend reports this error
    reset() expects parameter 1 to be array, string given.
    Any thoughts on this?

    Thank you.

    #30555
    Long NguyenLong Nguyen
    Moderator

    Hi,

    That means on the backend, the helper function gets the wrong third argument $post_id. You can try to put the post ID to the helper function and re-check it.

    $files = rwmb_meta( 'cf-den-1-ustanoveni', array( 'limit' => 1 ), 1234 );
    

    Get more details on the documentation https://docs.metabox.io/rwmb-meta/#arguments

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