Home › Forums › Add-ons › Flexible Content Field › Getting 5 latest Flexible Sub Fields and display in loop. › Reply To: Getting 5 latest Flexible Sub Fields and display in loop.
Hopefully you eventually found some solution for this. For anyone else that’s looking for something similar, there isn’t really any way to know which layout was created when or most recently. If you need to do something like this then you need to do something along the line of with the OP edit suggest. You need to hook into acf/save_post and set some additional meta values that indicate when a layout or some other value was created. See https://www.advancedcustomfields.com/resources/acfsave_post/ for more information on this hook.
Basically you can add this to happen before ACF saves values with a priority < 10 and you can compare the submitted values with what already exists. You can use the WP function get_post_meta to get values currently stored in the database and bypass ACF and compare those values to what’s in the $_POST array. Then you can update some other meta_key with the date that anything new is added and what was added, for example the layout row. This could get extremely complicated if someone decides to delete a row and I’m sure that it is far more complicated than this brief outline, but it might be a place to start.
Hope that helps someone.
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!
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future.— Advanced Custom Fields (@wp_acf) January 6, 2023
© 2023 Advanced Custom Fields.