Home › Forums › General Issues › Need help for auto-increment field with update_field › Reply To: Need help for auto-increment field with update_field
There really isn’t a way to do this simply.
There are a couple of choices.
The is to create an acf/save_post filter https://www.advancedcustomfields.com/resources/acf-save_post/. In this filter get the value of the field and save it as an option https://developer.wordpress.org/reference/functions/update_option/. Then create an acf/load_field filter https://www.advancedcustomfields.com/resources/acf-load_field/ and set the default value for the field based on the option.
Second choice. Create an acf/load_field filter. In this filter you do a query to get the posts of the post type. Order DESC by the custom field, limit the posts returned to only get 1 post. Get the value of the field on this one post and set the default value of the field based on this value.
Either has it’s pros and cons
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.