Skip Navigation

[Resolved] Display related child post on separate page than parent

This thread is resolved. Here is a description of the problem and solution.

Problem: I have two post types in a one-to-many relationship. I would like to create a link on the parent single post that sends Users to a differnt page containing a View, which should display the child posts of the original parent post.

Solution: In the View of child posts, add a Query Filter by post relationship, where the parent post is set by a URL parameter like wpv-related-to. Then in the parent post template, build a link with HTML and Views shortcodes to link to the correct URL, like this:

<a href="https://yoursite.com/some-custom-page/?wpv-related-to=[wpv-post-id]">Link to the page containing the View</a>

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-related-child-posts/
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

This support ticket is created 5 years, 11 months 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 2 voices.

Last updated by Waldo 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1194013

Tell us what you are trying to do?
I’m building a vacancy section on a charity site.
Is there any documentation that you are following?
I followed the custom post type, creating views, creating content templates and displaying related Child post documentation. All of these work fine and I am able to show child application submission made throug cred form via child post link on parent post single content template.

However, guests are able to see applicant details (I have used access to restrict the childpost content but I can’t restrict just the view calling the related child post in the single parent content template. And I don’t like having it there.

How do I create a view that calls the related child posts in a separate page from the single parent post content template
Is there a similar example that we can see?

What is the link to your site?

#1194019
Screen Shot 2019-01-31 at 5.54.22 PM.png

Hi, you can set the Post Relationship filter to respond to a shortcode attribute 'wpvrelatedto', like you see in the screenshot here. Then when you place the View shortcode on another Page or in another template, you can pass in the parent ID as a shortcode attribute. For example:

This will show the child posts related to parent post with ID '12345':
[wpv-view name='Your View of Child Posts' wpvrelatedto='12345']

This technique is called "Passing arguments to Views", and it helps make your Views dynamic. We have some documentation available here: https://toolset.com/documentation/user-guides/passing-arguments-to-views/

Let me know if you have questions about this.

#1194384

Hi can I swop out there later to with parent post, how do I distinguish between different parent posts

[wpv-view Name=‘your View of child post’ wpvrelatedto=‘12345’]

With

[wpv-view Name=‘your View of child post’ wpvrelatedto=‘$parent’]

#1195042

If the parent post is the current page, you can choose the Query Filter option "The post where this View is shown."

If the child post View is displayed in a View of the parent post, you can choose the Query Filter option "The current post in the loop".

If the child post View is displayed on a child post (sibling), you can use the wpv-post-id shortcode to get the ID of the parent post, then use it to set the value of the wpvrelatedto shortcode:

[wpv-view name='your View of child post' wpvrelatedto='[wpv-post-id item="@your-relationship-slug.parent"]']
#1195155

Thx, but I think I want to do something else than the options you gave.

I want to create a link from the parent post to a new page where I want to show a view that contains a list of the related child posts for the parent post I linked from.

That way I can use the same page and just create the link in the parent single content template.

I hope that make sense, and that there is a simple solution for that.

Thx
Waldo

#1195158

Okay yes, I understand. The simple solution here is to use a URL parameter to set the parent ID. In the screenshot of the Query Filter I posted earlier, you could choose the option "The post with ID set by a URL parameter: wpv-related-to".

Then on the parent post page, you can use HTML to create a link that includes the parent post ID in the URL parameter like this:

<a href="<em><u>hidden link</u></em>;">Link to the page containing the View</a>
#1195353

That worked great thx, Im getting to understand toolset better now.

One more question

How would I now draw other info from the parent post into this end page.

For example I want to show the parent post tiltle and then the child post list

"
This is the job Title (parent post title)
- An applicants who applied (this I now have)
- An applicants who applied
- An applicants who applied
"
thx

#1195355

Dont worry sorted it:

Created a new view showing parent title only and then called related child posts.

Easy, Should have done that from the start, but at least I learned something new thx

Waldo

#1195368

My issue is resolved now. Thank you!