Show advanced image by post ID

Support General Show advanced image by post IDResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #19600
    JeanROUSTANJeanROUSTAN
    Participant

    hi,
    i have a custom post type 'stock' with an advanced image field named 'photo'.
    I need to display the first image of my cpt (id=123) in a specific page.
    i've tried this, but this doesn't work

    $images = rwmb_meta( 'photo', array( 'limit' => 1,'ID' => 123) );
    $image = reset( $images );
    

    Is it possible to do this ? if so, how?

    #19601
    Long NguyenLong Nguyen
    Moderator

    Hi Jean,

    The code to get a field from a post ID should be

    $images = rwmb_meta( 'photo', array( 'limit' => 1 ), 123 );

    For more information, please follow the documentation
    https://docs.metabox.io/rwmb-meta/#arguments

    #19603
    JeanROUSTANJeanROUSTAN
    Participant

    so simple! Thanks 🙂

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