Skip Navigation

[Resolved] Create field groups through import?

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by briana-5 3 years ago.

Assisted by: Christian Cox.

Author
Posts
#1989353

The process of creating custom fields can be a tad tedious. Is there a way to create the the custom fields with their name and type in a CSV file and import those directly into an existing field group? I'm using WP All Import to import the CONTENT to existing fields. But I"m talking about creating the fields themselves.

#1989757

Hello, there is no built-in way to import field definitions with a CSV import, but it is possible to use the Toolset Export/Import feature to accomplish something similar. The file format involved is XML, not CSV. It will require some basic understanding of XML documents and coding structures, which are more complex than a simple CSV file. The Types export feature allows you to export all the custom fields in a site. If you create a couple of field groups and create one of each field type, then export the Types fields structure, you can open the XML file produced and see the general structures involved. You could use that as a template for creating various fields manually in an XML document. You can edit these files in any simple text editing software, or a code editor like SublimeText.

The XML export/import approach probably isn't much faster for creating the fields because of the complexity involved in the XML document, but can definitely speed up the process when adding options to fields that offer multiple options. Select fields, radio fields, checkboxes groups, etc, with several dozen options might be good candidates for this approach. In this case, it's usually best to create the field with at least one option manually in wp-admin. Then export those fields using the Toolset > Export function. An XML document will be produced containing the basic structure for all the fields, including the one option you created manually. You can copy + paste nodes in the XML document to create more options for each field, then import the updated XML document to update the existing fields structures.

Example export showing options for a select field with one option:

 <options>
   <wpcf-fields-select-option-06c4fcf4f3156f5121f98d1b3c4f155f-1>
     <title>Option title 1</title>
     <value>1</value>
   </wpcf-fields-select-option-06c4fcf4f3156f5121f98d1b3c4f155f-1>
   <default>no-default</default>
</options>

You could add a few more options to this select field like so:

 <options>
  <wpcf-fields-select-option-06c4fcf4f3156f5121f98d1b3c4f155f-1>
    <title>Option title 1</title>
    <value>1</value>
  </wpcf-fields-select-option-06c4fcf4f3156f5121f98d1b3c4f155f-1>
  <wpcf-fields-select-option-2>
    <title>Option title 2</title>
    <value>2</value>
  </wpcf-fields-select-option-2>
  <wpcf-fields-select-option-3>
    <title>Option title 3</title>
    <value>3</value>
  </wpcf-fields-select-option-3>
  <wpcf-fields-select-option-4>
    <title>Option title 4</title>
    <value>4</value>
  </wpcf-fields-select-option-4>
  <wpcf-fields-select-option-5>
    <title>Option title 5</title>
    <value>5</value>
  </wpcf-fields-select-option-5>
  <default>no-default</default>
</options>

Instead of the random looking hash number used in the nodename of the exported option, I've added sequential integers to create unique nodenames, and the system will handle it. Save that XML file and import it in Toolset > Export/Import > Types tab, and you'll see the new options appear in this custom select field.

And I should also mention the Toolset Module Manager plugin, which can be used to quickly share existing Toolset structures between sites. The structures for custom fields, custom post types, and custom taxonomies can all be shared between sites using the Module Manager plugin. So if you've already created a few custom fields and you want to import those into another site without transferring all Types settings, you can create a module with just those fields and import that into your new site quickly.

#1991647

Thanks. These are good tips. Consider that a feature request, perhaps. At a minimum, it might be time to revisit the UI for the edit Field Post Group. It’s a bit tedious to click “add new field”...get a pop up...select your field type...and go back to the page to enter info...then repeat. Eliminate the pop up, make single line the default field type and put most of the other Options under an advanced tab. Tabbing past the last visible form field creates a new field Would be so much faster.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.