I am going to create a custom field including a select option, I simply created 2 item for the custom field, I export the list and study the XML, I plan to make a new XML and the import to the Types, for example, I create the year select from 1964 to 2014. I found each item contain a long code <wpcf-fields-select-option-b3540f7040f44e197cab7dd1defb68b8-1>, how can I prepare the XML and import into the types? Not only the years, I still have several fields contain many select options, it is quite time consuming to add options one by one, any other suggestion?
The value "b3540f7040f44e197cab7dd1defb68b8" used in <wpcf-fields-select-option-b3540f7040f44e197cab7dd1defb68b8-1> is a random generated hash for some internal purposes. You can use your own random hash, or can simply omit the hash, and it should work.
Please give it a try and let me know if I can help you with anything related.
Is there any drawback if I don't provide the hash value in the XML?
To play safe, I usually export existing and then modify the XML before import. After modify, do I need to remove all existing before import? If no need to remove first, will the updated item in XML will replace the existing one?
I have used a minimal set of XML structure to define a Fields Group and to Link the field to the group. I have used a sample group. This group already exists in my Word Press under Types, with some existing fields (as mentioned in "_wp_types_group_fields" XML tags above), except the "year" field. Which I am going to add as a new field.
Also notice <wpcf-fields-select-option-1> and <wpcf-fields-select-option-2> sections in above XML. I have used an incremental number (1, 2) for SELECT field options definition. Please notice I haven't used any hash in the above XML.
When I import this file (Types -> Import/Export), it successfully interprets the file and shows me several options (as usual). It also shows me what's new found in the above file and what's going to update.
Finally, it updates the existing post type, with the addition of new field. I made some changes to the options of SELECT field, and imported the same file again. Types updated the new changes (overwriting the existing field).
Many thanks for your code, it works. It is very useful for developer who need to import a huge amount of data. It should be posted on knowledge base for other user to read it easily.