Home › Forums › Backend Issues (wp-admin) › Only save field in wp_postmeta when data is entered › Reply To: Only save field in wp_postmeta when data is entered
This could be done, but not without a bit of work. ACF saves every value, empty or not.
As far as a solution, I have not tested what follows so it’s only a thought about how it could be done. I have several sites that have thousands of posts in custom post type and usually much more than 10 fields. The empty rows don’t appear to effect anything as far as I can see so I don’t worry about the.
Anyway, you could create an acf/save_post action with a priority of 1. This will run before ACF saves the data. In your action function you could then delete/unset the $_POST indexes that have empty values. I think this would cause ACF to not save the fields to the database.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!