Skip Navigation

[Resolved] Update relationships between custom post types

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

This topic contains 6 replies, has 2 voices.

Last updated by chrisC-34 4 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1764375

Tell us what you are trying to do?

I have a wordpress site with, in the region of 20,000 custom posts written over about 20 years. Each post has a reviewer name in a custom field. I also have a custom post type called "Reviewers" which includes their first and last name, a short biography and their specialities.

I am looking to create a page that will list all the reviewers (which I have here: hidden link) that links to their profile. This seems to work (see here: hidden link for example)

Below each profile I wish to list all the articles that the reviewer has written. This is where the relationships works so well.

On each of the custom-posts I can connect an existing reviewer, which works well as I can search for the reviewer's name and a relationship is formed. As you can see on the David Gutman profile there are 5 reviews that I have manually formed the relationship as a test.

My question - is there a simpler way to make each of the 20,000+ posts related to their respective reviewer, other than going through each and adding the relationship manually?

I had a look at the database tables on phpMyAdmin and found wpwf_toolset_relationships table but that isn't it and I am sure that it is much more complicated than simply copying one set of fields to another.

Any advice would be appreciated.

Thanks

Chris

Is there any documentation that you are following? No

Is there a similar example that we can see? No

What is the link to your site? hidden link

#1764523

Shane
Supporter

Languages: English (English )

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

Hi Chris,

Thank you for getting in touch.

Perhaps you can make use of the function in the link below.
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

However it begs the question how will you determine which posts should be connected to which.

Thanks,
Shane

#1764953

Hi Shane,

Thanks for the links - I did have a look at those but I can't really see how it would help using the relationships API.

It should be easy to tell which posts are connected to which, as, when looking at each post there is a custom field called "Reviewer". It would be nice if I could "bulk edit" the relationships for each post, however it seems that option isn't available out of the box.

Do you know of any way for me to bulk edit the relationships? Are relationships a toolset feature or are they something that a plugin might be able to deal with? I don't mind sorting the posts by reviewer names (that is easy to do visually) and then select them and 'bulk update' if that was possible.

Any thoughts on the matter would be appreciated.

Chris

#1765361

Shane
Supporter

Languages: English (English )

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

Hi Chris,

Do you know of any way for me to bulk edit the relationships?

No there is no way in the user interface to bulk edit the relationships, this will all need to be done with custom code.

Are relationships a toolset feature or are they something that a plugin might be able to deal with?

The post relationships are a feature of Toolset so another plugin won't be able to manage this.

I don't mind sorting the posts by reviewer names (that is easy to do visually) and then select them and 'bulk update' if that was possible.

From this I gather that Post Type A has a custom field called reviewer that can be used to sort Post Type A, however in Post Type B how can we determine which Posts should be related to Post type A. Either way the bulk edit would need to be completely custom.

Thanks,
Shane

#1765943

Thank you Shane. That is what I was afraid of (that a bit of custom code would need to be written).

As you quite correctly point out, while all posts in Type A have a link to the reviewer in post type B, there is no relationship in type B that will link back to the multiple reviews of type A.

I own a licence to WP All Import Pro that, apparently, will allow relationships to be created. So I might try exporting the database and try reimporting it on a test machine to see what I can achieve in that way.

Thanks anyway for your help on this one...I think it is likely to be a bit of a slog.

Chris

#1766337

Shane
Supporter

Languages: English (English )

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

Hi Chris,

Happy I was able to assist you. I know with the WP ALL Imports Pro you should be able to bulk edit the relationships with the CSV/XML files and import them and it will work.

https://toolset.com/2018/10/wp-all-imports-integration-with-toolsets-types-fields-and-post-relationships-makes-it-easy-to-import-your-data/

If there are no further queries on this one then you can go ahead and mark this issue as resolved.

Thanks,
Shane

#1767737

My issue is not fully resolved - I need to look at this further myself. Thank you!

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