Hello @geekayhu,
I see that you posted the topic on the ACF plugin support: https://ww.wp.xz.cn/support/topic/deleting-content-of-conditional-field-issue/. The issue you’re facing is very well-known by experienced ACF developers. In fact, the philosophy of ACF is to almost never delete values (some fields are an exception, like Flexible Content or Repeater).
Just so you understand how it works behind the scene, when you hide a field using a condition, the said field is automatically set to disabled="disabled". Which means it isn’t submitted when saving the page (not present in the form $_POST), and ACF isn’t even aware of it during that save/update/delete process. This is why you’ll see that even when you actually clear a field value, then hide it using a condition, the value will “reappear” if you display the field again after the page save.
There is a workaround tho. ACF Extended provides a feature called “Single Meta Save” (which you’ll find in the readme). This feature will compress all ACF meta values into one single meta and comes with an option called “Clean orphan metas”. This option will actually clean any field that doesn’t exists anymore (in the Field Groups UI), but also those who are hidden by conditional logic.
Here is a video example for your case: https://i.imgur.com/l9PZB3n.mp4
Note that at 00:17, I enable the “Single Meta Save” feature. It is also possible to always “Clean orphan metas” using a simple line of code.
Let me know if you have questions!
Regards.
Hi there,
now it makes sense if ACF kinda “intentionally” works this way… So we just have to delete/save (content) one by one. Fine, good to know. That’s how we’ll do.
Thanks for your assistance
Have a great day
Kind regards
Gabe