Home › Forums › Add-ons › Flexible Content Field › Populate Flexible Content Rows Programmatically › Reply To: Populate Flexible Content Rows Programmatically
Yes, this makes sense. I’m able to find and target the flexible content area, but I’m not finding much success once I have that target to add more layouts or rows to that flexible content field.
It looks like I have to set the focus to that element and then the acf.fields.flexible_content object is updated and when I add elements it goes to the right place, but that doesn’t seem to be working 100%. I can set the focus with trigger.(‘focus’) or simply .focus() but it still doesn’t add them all the time. If there are multiple flexible content fields, I’m not sure how to set the acf focus to one vs the other via the script. It does seem to work however if I click the ‘add row’ button to focus on that flexible content field and then trigger my script. So I’m doing that for now, not ideal, but functional at least. Still saving quite a few clicks.
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.