Support

Account

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.