Skip Navigation

[Gelöst] Do Not Understand Repeating Field Group Data

This support ticket is created vor 3 Jahren, 1 Monat. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 8 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von aaronM-9 vor 3 Jahren, 1 Monat.

Assistiert von: Shane.

Author
Artikel
#2194107

I have a repeating field groups in 'posts' called 'post-media'. Each record of the repeating field group has the following fields:

- wpcf-post-media-type
- wpcf-post-audio-source
- wpcf-post-video-source
- wpcf-post-media-url

I realized a flaw in my design and I need to reassign the data into new custom fields in the 'post' that are NOT in a repeating field group. The trouble is, I can't for the life of me figure out how the data is all connected in the database. I can see that wpcf-post-media-url is a meta value connected to a 'post-media' entry, that the relationship ID is 10, but then I can't figure out how to connect the dots from there. I thought it was the associations table but I can't seem to figure it out. Basically, I want to run a SQL query that outputs the following fields together on one row:

- POST_ID (the actual 'post')
- wpcf-post-media-type
- wpcf-post-audio-source
- wpcf-post-video-source
- wpcf-post-media-url

If I can get an export of that data then I can get everything straightened out. Thanks for any help.

- Aaron

#2194141

Shane
Supporter

Sprachen: Englisch (English )

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

Hi Aaron,

Repeatable field groups are created as Post Types. What this essentially mean is each repeating field is a Post and in those posts they have the different custom fields.

So you should be looking to find the post ID of each of the repeating groups and then check the post meta table to find your custom field.

From there you should be able to retrieve the data. You may even be able to simply change the associated Post ID of the database entry to map the field to a different post.

Please let me know if this helps.
Thanks,
Shane

#2194989

Hi Shane,

Sorry - I'm still struggling with this. Based on your suggestion, the issue I am having is knowing which 'post' ID is connected to the 'post-media' ID. I can easily run a query that shows me all 'post-media' entries, but the trouble is linking them to the original post.

For example, post_ID 10962 is type 'post-media'. I can see the meta entry for the custom field value I want to move over. However, when I search for ID 10962 in the toolset_associations table - regardless of whether I search under parent_id, child_id, or intermediary_id - NOTHING comes up. I know for a fact there is a related post because I can see it in the GUI, but I need to know how to connect the dots in the database so I can run a query that updates all the records. So, how do I connect a 'post-media' entry to a 'post' entry?

- Aaron

#2195243

Shane
Supporter

Sprachen: Englisch (English )

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

Hi Aaron,

What you can so is to create a view that will list out the Repeatable field groups on the page. From there you should be able to use the [wpv-post-id] shortcode to see the ID of the post that is connected to the field group.

I can see the meta entry for the custom field value I want to move over. However, when I search for ID 10962 in the toolset_associations table - regardless of whether I search under parent_id, child_id, or intermediary_id - NOTHING comes up.

I did an extensive check on the database to see if I can change the posts the field groups belong to. The good news is i'm able to succeed.

Now you should first check the wp_toolset_connected_elements table for you Post ID that you want to connect your other RFG to. I would recommend creating atleast 1 RFG on this post so that the Post's ID is logged into the wp_toolset_connected_elements table.

Secondly there is a column called element_id. This column will hold the ID of your Post, not the ID of your RFG post. Now beside that you should see an ID column. Memorise this ID.

Next you will need to go to the wp_toolset_associations table and there you should see a Parent_ID. You will need to change that ID to the ID of post that is in the wp_toolset_connected_elements table. Confusing I know.

You RFG post ID's are also stored in the wp_toolset_connected_elements table. So you will need to find your RFG post ID and then using the ID column to find it in the wp_toolset_associations under the child_id column.

Finally once you've made a mental note of the ID's you will then go to the wp_toolset_associations table and change the Parent_ID to the ID of your Post from the wp_toolset_connected_elements table.

In summary the only 2 tables you should be looking at is the toolset_associations and toolset_connected_elements as they contain all the information you will need including the IDs of the posts and the rfg posts.

Please let me know if this helps.
Thanks,
Shane

#2195877

Sorry, I'm finding your explanations difficult to follow. Can you please explain to me what the "group_id" field in the "toolset_connected_elements" table refers to?

- Aaron

#2195903

Okay, I think I've figured this out:

The toolset_associations table relates two "groups" from the toolset_connected_elements together. The first element has the 'post' ID and the second element has the 'post-media' ID.

I will work on building a query and close the ticket once I have confirmation.

- Aaron

#2195905

Shane
Supporter

Sprachen: Englisch (English )

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

Hi Aaron,

I cant say for certain but it appears to be related to the child_id column in the toolset_associations table.

Please let me know if there are any further queries.

Thanks,
Shane

#2195985

I'm confirming I was able to figure this out and successfully create a SQL query that links the post-media entry back to the post. Basically, here is how it works:

1) post ID from repeating field post meta = element_ID in toolset_connected_elements table
2) group_ID in line 1 = child_ID in toolset_associations table
3) parent_ID in toolset_associations table = group_ID in toolset_connected_elements table
4) element_ID in line 3 = post_ID of the original post

With this logic you can setup your inner joins in SQL and get the data you want. Hope this is of help to anybody else. Thanks.

- Aaron

#2195991

My issue is resolved now. Thank you!