AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
823 stars 168 forks source link

Cannot set attachments in relationship fields after recent update #825

Closed robrecord closed 1 year ago

robrecord commented 1 year ago

Regression

Since around version 6, it is no longer possible to set an attachment in a Relationship field.

This is because the default post status for attachments, 'inherit', is no longer being recognised by ACF by default.

It's not clear to me where this bug is happening, since normally get_post_stati() does include 'inherit', but certainly by the time it's being used in ACF, several types have been weeded out of the list, included "auto-draft" and "acf-disabled".

A temporary workaround is this (in theme functions.php):

add_filter('acf/get_post_stati', function ($stati) {
  $stati['inherit'] = 'inherit';
  return $stati;
});

This is happening on my current website; I will try to determine whether another plugin is causing this and report back if so. Still, the changes introduced do not ensure that attachments can be used in this way, and I believe ACF should ensure this.

lgladdy commented 1 year ago

Hey @robrecord, which version of ACF are you running?

This should have been fixed in 6.1.4 last month.

robrecord commented 1 year ago

Thank you! I missed that update. I am on 6.1.3. I'll update and report back if it's still happening.

Thanks for the quick reply.

robrecord commented 1 year ago

You're right - it's fixed. Thanks once again!