Support

Account

Home Forums General Issues Gallery: Related Images "Uploaded to"… Problem! Reply To: Gallery: Related Images "Uploaded to"… Problem!

  • 
    add_action('acf/save_post', 'remove_att_from_att');
    function remove_att_from_att($post_id) {
      $post_type = get_post_type($post_id);
      if ($post_type != 'attachment') {
        return;
      }
      $children = get_children($post_id);
      if (children) {
        // remove filter so this filter does not run again
        remove_filer('acf/save_post', 'remove_att_from_att');
        foreach ($children as $child) {
          $child->parent = 0;
          wp_update_post($child);
        }
        // restore filter
        add_action('acf/save_post', 'remove_att_from_att');
      }
    }