Support

Account

Home Forums Backend Issues (wp-admin) ACF load_value to Gallery Field Reply To: ACF load_value to Gallery Field

  • To be honest, I’m not clear on what you’re trying to do, but hopefully correcting a couple of issues I see in your second code snippet and answering your questions there will help.

    first, at the top of your function you need to return the current value if set

    
      if (!empty($value)) {
        // already has a value
        return $value;
      }
    

    the question

    
    
      // How to get the Slider ID of current post?
      $id = 123;
      $table = $wpdb->prefix . 'new_royalsliders';
      $slider_data = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $table WHERE id=%d", $id), ARRAY_A );
    
    

    should be something like

    
    $id = get_field('media_gallery_slider', $post_id, false);