Hi there, I am trying to receive data with using webhook and creating custom posts, depending on the data that I received
I need to create one parent post and multiple child posts. Since these posts will not be created manually. I am not able to create this relationship with Toolset type. both the parent and the children posts are the same unique ID, let's call it as unique-id, so, I think I can use this unique-id to create the relationship and display them but how to?
Parent A, child B, Child C, and Child D. all of them have the same unique-id value. then display all data related to child c, child b, and child D on the Parent A post. Thank you so much!
I'm not sure about the details of what you intend to do. For example, parent and child posts have the same unique ID. I assume you mean that in the data you receive there are posts with the same ID and you want to create parent and child posts within your WordPress site from this data and connect them using Types relationships.
Recall, all posts in WordPress must have a unique post ID, they cannot be the same.
So I expect you receive the data, and you use the WordPress API to publish posts.
Thank you for the response, I guess something that makes confused. Let me take an example with house and rooms. I have received data with webhook for both post types and stored unique fileds like this
House A , house id: 123; room A, house id 123; room b, house id 123.
and
House B, house id 456; room c, house id 456; roomb, house id 456.
My purpose is to diplay each post like. House A includes room A and room B; House C includes room C and room D. Since the data was recived by webhook and were not created manually. I am not able to display posts with Toolset relationship view.
How can I do for this situation?
Have a nice day
It is possible to query posts by custom fields values. see below demo site:
Login URL: hidden link
1) Create a post view "Related room posts": hidden link
- Query Room posts
- Filter by:
Select items with field:
house-id is a string equal to VIEW_PARAM(houseid)
- In view's loop, display room information
2) In the single "House" post hidden link
you can get the custom field "house-id" value with shortcode:
[wpv-post-field name="wpcf-house-id"]
Pass field value to above post view's shortocde, like this:
[wpv-view name='related-room-posts' houseid='[wpv-post-field name="wpcf-house-id"]']