Skip Navigation

[Resolved] Relation between 2 cpt

This support ticket is created 6 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
- 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)

This topic contains 9 replies, has 2 voices.

Last updated by Luo Yang 5 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1202477
Capture2.JPG
Capture.JPG

Hi,

I have created two CPT (carnet de voyage and createur).
After that I created a view who listed the carnet de voyage on the page of a createur.
On carnet de voyage I have a dropdown to select the relative createur
The view work well but I didn't know how to filter the view to display on the page of the createur the carnet for this specific createur

thanks for your help

#1202806

Hello,

I assume we are talking about this case:
1) Two post types:
- createur
- carnet de voyage

2) One "createur" post can connect to multiple "carnet de voyage" posts.
One "carnet de voyage" post can connect to only one "createur" post.

If it is, you can setup one-to-many relationship between post type "createur" and "carnet de voyage", see our document:
https://toolset.com/documentation/post-relationships/

In a single "createur" post, create a post query:
- query "carnet de voyage" posts
- filter by the post type relationship
- display "carnet de voyage" post information

See our document:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-related-child-posts/#3-creating-a-view-that-lists-the-children-of-the-parent-post

#1203733
Capture.JPG

Hi,

thanks for your reply not sure to understand how to do that.
I have this error " This will filter out posts of the following types, because they are not related to any other post type: Carnets de voyage"

thanks

#1204167

As I mentioned above, you can setup one-to-many relationship between post type "createur" and "carnet de voyage", you can setup the post type relationship here:
Dashboard-> Toolset-> Relationships

see our document:
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

#1204611
Capture.JPG

Hi,

thanks it's ok for the relationship but I have no result in the view (no item found child)

Regards

#1205224

This is abnormal, please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2019, and test again

3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1211625

Thanks for the details, I am downloading the files, will update here if there is anything found

#1211626
add-child-posts.JPG

Here are what I found, in the problem post "Laure Aouabed", there isn't any child "Créateurs Carnets de voyage" posts:
hidden link

To test the view's results, you can add some posts in section "Créateurs Carnets de voyage", see screenshot: add-child-posts.JPG

See the result here:
hidden link
section "MON CARNET DE VOYAGE"

#1211740
Capture.JPG

Hi,

thanks I didn't see this new feature.
But this relation must be chosen in the carnet de voyage "test 1".
There is a dropdown where we can choose Laure Aouabed.
Because it's more simple to associate immediately the carnet de voyage to a person rather than search after thousand of carnet de voyage.

Thanks for your help

#1211748

You can connect those posts with each other in both end, for example, you can edit the single "Carnet de voyage" post: test 1

hidden link

in section "Créateur Carnet de voyage", click link "Se déconnecter" to remove the connection, then connect it to other parent "Créateurs" post.

Since it is one-to-many relationship, so:
- each "Carnet de voyage" post can connect with only one "Créateurs" post,
- each "Créateurs" post can connect with multiple "Carnet de voyage" posts,

See our document:
https://toolset.com/documentation/post-relationships/