Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

Need to access the last ACF Flexible Content Field?

Olivia Rhye
Need to access the last ACF Flexible Content Field?

So, some developers would just list them all and hide all but the last one. That works fine, but if the field volume gets pretty large you will have a heavy page load even though you only want to show a single field. To access the last (usually most recent) ACF Flexible Content Field by itself you have to look at it as an array. The array would start at zero and count to as many flex fields that you have. The tough part is not always knowing how many fields you may have for a particular post/page and if you just want to access the most recent field it could be a guessing game.

My solution is simple. Using basic php you can access the Flex Content section directly as an array. Reverse the array which would then make the most recent flex field the first item. Then use that to get the sub field(s) needed from said flex field.

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy