Support

Account

Home Forums Add-ons Gallery Field Gallery field to save image order in database? Reply To: Gallery field to save image order in database?

  • 
    // post ID in second arg
    // false in 3rd arg gets the unformatted value
    // this will return an array in the order that the images
    // are in the gallery
    $gallery = get_field('your-gallery-field', $post_id, false);
    // use this array to query the attachments
    $query = new WP_Query(array(
      // other query arguments
      'post__in' => $gallery,
      'orderby' => 'post__in'
    ));