Home › Forums › General Issues › Populate ACF Repeater field from a list/CSV/XML
I have a repeater field on the options page, which I have to populate with 300+ rows.
These won’t be dynamic, but I have a spreadsheet of the rows with the appropriate values. I can create any type of file from them (XML, CSV, JSON, whatever is the easiest). I just don’t want to manually add 300+ rows…
Is there any ways to do this?
I have looked into WP All Import but it doesn’t seem to work, especially on the options page (yes I have the ACF Addon as well).
300+ rows in a repeater does not sound like a good idea. There aren’t any plugins that will do this. You’d need to build your own script to read whatever file you upload and do the importing. It would likely take as long to build the script as type in the 300 rows.
Is there are reason you’re not using a CPT, a post for each row? WPAI could do it if you went that route.
I’m interested why you don’t think 300 rows is a good idea – surely a CPT has more database overhead?
Anyway, this post helps;
https://felicoz.com/en/2017/05/acf-import-repeater-field-values-csv-programmatically/
if you add the line
add_row('repeater_name', array("",""));
in the while
loop, (obviously as many empty values as sub fields), then it will add the rows too.
There are several reasons I don’t think 300+ rows in a repeater are a good idea.
One of those reasons is management. The admin for this repeater will be difficult to use.
Another reason is the potential for timeouts and other errors when saving.
PHP has a limit on the number of input variables. It can be adjusted, but if you go beyond this there is not warning, you simply see rows disappear, unless you have a script in place that gives a warning when the number is exceeded.
Another potential issue is timeouts when saving. Depending on the data in those rows there is the potential that saving will fail because it takes longer than 30 seconds.
Also, if I have a repeater that will likely have this number of rows then I’m probably not using the right tool for the job. More than likely the data would be better served by using a custom post type or a custom taxonomy, depending on what data needs to be stored. This may not always be the case, but I would explore other options to make sure that a repeater was the right choice.
The topic ‘Populate ACF Repeater field from a list/CSV/XML’ is closed to new replies.
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.