Skip Navigation

[Resolved] Repeatable Group – Set-up and Import data via WP All Import

This thread is resolved. Here is a description of the problem and solution.

Problem: I have an RFG set up on my site, and I would like to import content using a CSV import tool.

Solution: You should import each row of the RFG as though it is a new post, where the post type slug is identical to the RFG slug. The column format for the CSV file is dependent upon the CSV import tool you are using, but usually must include a column for specifying a parent post title or GUID with the column header format _toolset_associations_{RFG slug}. There should also probably be columns for post title, post author, and any custom fields you want to import for each row of the RFG. See the examples provided in this ticket for more information, and refer to the documentation for your preferred CSV import tool.

Relevant Documentation:
https://toolset.com/course-lesson/importing-content-from-csv-with-post-relationships/

This support ticket is created 4 years, 1 month 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)

Author
Posts
#1852675

Tell us what you are trying to do?
Hello,

I'd like to set-up individual race results posts where the repeatable group custom post type consist of the results displayed as a table. (Place, name, time, etc)
I've successful set up a sample within my sandbox site, see table below the image: hidden link
My questions are:
1) Is this the best way to approach to display race results as a table?
2) I would like to import each race post and the repeatable fields content. I'm having difficulty devising a system where the results can be imported via WP All Import toolset into a repeatable group. Might you have a better solution for importing data?

Is there any documentation that you are following?
Yes, I've read through the docs and watched the views and templates videos numerous times to try understand repeatable groups in more detail.

Is there a similar example that we can see?
Sandbox Work in progress hidden link
What is the link to your site?
Sandbox hidden link

Ideally I will import information via json endpoint. Maybe there is another way to set-up custom fields that I'm not seeing?

Thank you for your time!

#1852723

Hi, thanks for reaching out.
1) Is this the best way to approach to display race results as a table?
In terms of the wp-admin setup of Toolset structures, I think you have the right idea. Since you have a repeating set of fields that are associated with one post, a Repeatable Field Group (RFG) setup in the Race post type is an effective approach. Another option is a one-to-many relationship between Race posts and Results posts, where Results is a separate custom post type. One advantage of the RFG approach is that you can easily edit each row of the RFG within the Race post editor screen, whereas editing each child post from within the Race parent post editor is a bit more tedious. One advantage of the separate custom post type approach is that each Result post is automatically given its own URL for front-end display as a custom post type.

2) I would like to import each race post and the repeatable fields content. I'm having difficulty devising a system where the results can be imported via WP All Import toolset into a repeatable group. Might you have a better solution for importing data?
I don't have any information specific to importing RFGs with this plugin, but I might be able to offer some additional guidance. Under the hood, RFGs are technically stored in the database as a custom post type in a one-to-many relationship with the parent post type. Both the RFG post type slug and the post relationship slug are identical to the RFG slug you can find in the Toolset > Post Fields editor screen for the field group containing the RFG. So in theory, importing RFGs into an existing parent Race post can be accomplished by following instructions to import child posts in a one-to-many relationship where the relationship slug is identical to the RFG slug. The child posts must contain the custom field values of the RFG. We have information about using a generic CSV import tool available here: https://toolset.com/course-lesson/importing-content-from-csv-with-post-relationships/
In theory, the association between the RFG and the parent post type would be first established in this CSV as a postmeta value, then the Toolset Import/Export tool would be able to convert that into a true Types post relationship after the import.

If you have trouble setting this up, I might be able to download your CSV file and run some tests locally to confirm this is possible.

#1857717
Screen Shot 2020-11-26 at 9.18.01 AM.png
Screen Shot 2020-11-26 at 9.18.33 AM.png

Hello Christian,

Thanks for the information and feedback! I believe I understand your response in item 2 however the repeatable fields are not available as a choice under the relationships one to many.

Here is a sample CSV for download: hidden link
I've attached a screenshot of the custom fields group 'Individual Results Details' with the repeatable group 'results-details'.
The post name is 'Race Two'
The repeatable field groups are 'Place', 'Athlete Name', 'Time'

Any guidance you can offer on the best way to import would be appreciated!

And Happy Thanksgiving!

#1858103

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Janet,

Christian is currently on holiday today but he will be back on Sunday to continue assisting with this.

Thank you for the continued patience.

#1860539

I believe I understand your response in item 2 however the repeatable fields are not available as a choice under the relationships one to many.
Correct, you should not create an RFG relationship in Toolset > Relationships manually, nor should you create a custom post type for this RFG manually. Instead, the relationship and post type are automatically created in a hidden way when you create the RFG in Toolset > Custom Fields > Post Fields. Sorry for the confusion, I was not clear enough about that. Since you seem to have already created the RFG in Toolset > Custom Fields > Post Fields, there is nothing else you need to do to create this hidden post type and hidden relationship, as they were already created automatically. Now that the RFG has been created in the appropriate Field Group, each "row" of the RFG should be imported as though it is a new post, where the custom post type slug and relationship slug are identical to the RFG slug, results-details. The import CSV file containing each RFG post must include in each row the GUID (or parent post title, but GUID is better in case multiple parents with the same title exist) of the post which will contain that row of the RFG. You can find the GUIDs of parent posts in the [dbprefix]_posts table of your database.

https://toolset.com/course-lesson/importing-content-from-csv-with-post-relationships/#an-example-of-how-a-csv-would-look-like

For example, if an existing 'parent' post with GUID https://yoursite.com/?post_type=parent-post-type-slug&p=123 should contain 3 rows of results-details RFGs, there should be a CSV file with 3 rows. The CSV file should include, among any other necessary import data, a column header of post_type, and the post_type value for each row should be results-details. There should also be a column header of _toolset_associations_results-details, and the value in that column for each of the 3 results-details rows should be https://yoursite.com/?post_type=parent-post-type-slug&p=123. If you want to import field values into each row of the RFG, there should be a column for each field. The field slug format for Types fields is wpcf- plus the field slug shown in wp-admin. For example, if the field slug in wp-admin is book-rfg-num, the column header should probably be wpcf-book-rfg-num.

You can add multiple RFG rows in the same CSV import, with different 'parent' post GUIDs for each row.

The format of the CSV file is very specific, and depends on the import tool you're using. For example, the CSV Importer plugin (https://wordpress.org/plugins/csv-importer/) uses a specific table column/header format as shown in the example CSV file here:
https://drive.google.com/file/d/1qonHvf6fruOsJTVLk4ym51wetzL_ZxuI/view?usp=sharing
The example CSV file there shows how you would import 4 RFG rows into 2 different 'parent' posts, with two custom field values in each RFG.
- The ID column contains a unique number for each row
- The post author column (csv_post_author) contains the username of the post author
- The post title column (csv_post_title) contains text that will be shown as the header of the RFG row in the post editor screen
- The post body column (csv_post_post) and post excerpt column (csv_post_excerpt) are required for this import tool, but can have empty values

After importing the CSV file using the CSV Importer tool, you would then go to Toolset > Export/Import > Associations, run the Associations import process, and thereby associate each RFG row with its parent post. Then you would see the RFG rows appear in the post editor screen of the parent post.

#1862675

My issue is resolved now. Thank you!