How to either import posts with the custom fields?
ACF uses a post type and custom field metadata to save all the custom field objects.
This means you can use the export feature in ACF to obtain a .xml file which you can import into a WP install via the default WP import tool!
Or how to get all fields of a field group?
Are you asking how via code?
I checked out the dump from the custom fields export. It looks like it stores all the data from the actual value as a PHP serialization. This creates a problem for what I’m trying to do. I need to bulk import from a csv a custom post type that has custom fields. I’m using your custom fields plugin for the fields. I have plugin that used to import fields with your plugin. It seems like the code has been deprecated since then.
In PHP, how would I get all the fields of a field group along with the rules? Your documentation is very clear on how to do that.
i was able to figure it out. For anyone else wondering…
// To get field groups: $fieldgroups = apply_filters('acf/get_field_groups'); // To get rules: $location = apply_filters('acf/field_group/get_location', , $fieldgroup['id']); // To get fields of group: $groupFields = apply_filters('acf/field_group/get_fields', , $fieldgroup['id']);
Anyone that stumbles across this post in need of help with importing a CSV of posts into WP, try out this plugin. It allows you to add columns for all of the default WP fields like the_title, the_content and so on. It also allows any custom fields to be added as columns, so ACF is completely compatible.
In fact, you can even stick a repeater field into the CSV. I done this for a recent site.
You’d have the columns like:
repeater_0_text, repeater_1_text, repeater_2_text, repeater_3_text
And then another just called ‘repeater’, with the amount of sub-fields (in this example, the value would be 4).
Give it a try! Hope this helps someone one day.
http://wordpress.org/plugins/csv-importer/screenshots/ (I know it’s old, but it works)
Also as rmdev stated above, if anyone stumbles across this particular post I too import ALOT of data to my various sites, BUT I use WP Ultimate CSV Importer simply because it maps well to the fields of the DB including the custom fields from ACF. No need for urlencode and I’m normally importing 1000’s of records for my updates, no problems.
I also use Navicat because I can map to specific fields, but ONLY when I can deal with field(s) that I’m only updating data that is already there! Keywords are “data that is already there” as in update/append the field.
Whew! I just tried it and it mostly worked.
I ran into a funny bug where field that alphabetically fall lower than “f” don’t map. So I had to rename my fields to bump them higher alphabetically (first_name became “a_first_name” and so on). Once I did that, it worked.
I really appreciate the tip. I was scared that I was going to have to build out 500+ employees manually. So I’m thrilled that this will take care of the bulk of the data.
The topic ‘Need help with fields, developer question.’ 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!