Saltar navegación

[Resuelto] How to add repeating field groups to post with PHP

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

How to import post data using CSV file?

Solution:

You will need to setup the custom fields/taxonomies/post types in the target WordPress website:

https://toolset.com/course-lesson/creating-custom-fields/

https://toolset.com/course-lesson/creating-a-custom-taxonomy/

https://toolset.com/course-lesson/creating-a-custom-post-type/

Then follow our document to setup the CSV file, and import it to your WP site:

Relevant Documentation:

https://toolset.com/course-lesson/how-to-import-content-into-wordpress-using-csv/

This support ticket is created hace 3 años, 11 meses. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Etiquetado: 

Este tema contiene 5 respuestas, tiene 2 mensajes.

Última actualización por Luo Yang hace 3 años, 11 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#1975221

Tell us what you are trying to do?

I need to import 700+ posts to a Toolset custom post type that has custom taxonomies, custom fields and a custom field group with 3 fields in it. I know how to add the regular custom fields and how to put the posts in the right taxonomy terms and add the term if it doesn't already exist. I can't find any documentation on how to add the custom field group to the post (some could have 8 or more instances of the group and its fields).

Do I just create a post in the custom field group's post type and add the fields then connect it to the parent post as a parent child relationship or is there a Toolset API that makes this simpler?

Is there any documentation that you are following?

Could not find documentation that explains this process.

Is there a similar example that we can see?

Not that I know of.

What is the link to your site?

There's nothing on the site for this yet. I'm trying to build the code to do the import and this is the last piece I need to add and test.

#1975439

Hello,

I suggest you try these:
1) In the original website:
Dashboard-> Toolset-> Export/Import
Export the Types setting file, it should be able to export all Toolset Types plugin settings into one file.
Dashboard-> Tools-> Export
Find and export your custom post type posts data, this should be able to export posts contents/taxonomies/custom fields values

2) In the target website:
Same as above import the Types setting files + post data

More help:
https://wordpress.org/support/article/importing-content/

#1975827

I guess I wasn't clear. The data isn't coming from WordPress / Toolset. It is in a CSV file. There is no existing Toolset post / taxonomies / fields to export out then import in from.

#1977953

You will need to setup the custom fields/taxonomies/post types in the target WordPress website:
https://toolset.com/course-lesson/creating-custom-fields/
https://toolset.com/course-lesson/creating-a-custom-taxonomy/
https://toolset.com/course-lesson/creating-a-custom-post-type/

Then follow our document to setup the CSV file, and import it to your WP site:
https://toolset.com/course-lesson/how-to-import-content-into-wordpress-using-csv/

#1978555

I didn't ask how to use someone else's importer. I asked how to add repeating fields via PHP which is a topic missing from Toolset's developer documentation.

Also, I already invested in WP All Import, at Toolset's advice but they don't handle repeating fields yet. I'm not going to spend more money on Ultimate CSV Importer.

Because I solved the problem myself after some further experimenting, you can close this ticket. For others interested in the solution, I basically did what I asked about above:

Create the new CPT, put it in any taxonomies that are needed, add any non-repeating custom fields that are needed. Then create another new post using the custom field group's post type (the slug for the repeating field group), add the individual fields to this post, then connect this post to the first post using the correct relationship slug and the Toolset Connect Post API.

#1979227

You can use WP built-in function add_post_meta() to add items into multiple instances field, see the document:
https://codex.wordpress.org/Function_Reference/add_post_meta

As your request, closed this ticket