Hi,
I'm trying to create single post template for my website, the single post will include the information of it's parent relationship.
Eg: A real estate project features the information about it's project location and agent.
I went through the "real estate" Toolset template and learned how to setup, however the front-end using css to customize is frustrating, so I'm using Elementor single template instead. Everything was fine with Elementor dynamic field except I could not find a way to display the parent relationship in a single template.
Is there anyway to achieve this? Thank you
Hi,
Thank you for contacting us and I'd be happy to assist.
There are a couple of ways you can achieve this:
1. Using the "item" attribute:
If you just need to show the data from a single or a few fields from the parent post, you can use the "item" attribute with the Types Fields API shortcodes ( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/ ) and the View's shortcodes ( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#displaying-data-2 ) which show an individual post's data.
https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/
Examples:
Assuming that on your website, these are the slugs for the parent, child and the post-relationship:
Parent post slug: project-location
Child post slug: real-estate
Relationship slug: project-location-real-estate
To get the value of the custom field with slug "example-field" from the parent post:
[types field="example-field" item="@project-location-real-estate.parent"][/types]
To get the title of the parent post, using the "wpv-post-title" shortcode:
[wpv-post-title item="@project-location-real-estate.parent"]
2. Using a post view:
If you'll need a collection of values from that parent post, it would be better to create a post view to show the related parent post's data and then call that view in your child post's template.
Here is a guide on the topic:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Exellent! Thank you so much!
Please feel free to mark my question as resolved