Skip Navigation

[Resolved] View showing other users child posts within the same parent post

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

Problem:

I would like to aggregate all of the child posts that are published under the same parent posts where a user also has a child post... But users are able to create child posts under multiple parent posts. So, this view would need to show all of the child posts from each of the parent posts where they have also created child posts. Is this possible?

Solution:

You can try these:

https://toolset.com/forums/topic/view-showing-other-users-child-posts-within-the-same-parent-post/#post-1850443

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

This support ticket is created 3 years, 5 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
- 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 7 replies, has 2 voices.

Last updated by aaronW-4 3 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1849249

Tell us what you are trying to do?
I would like to aggregate all of the child posts that are published under the same parent posts where a user also has a child post... But users are able to create child posts under multiple parent posts. So, this view would need to show all of the child posts from each of the parent posts where they have also created child posts. Is this possible?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#1849463

Hello,

Please elaborate the questions with more details:
this view would need to show all of the child posts from each of the parent posts where they have also created child posts. Is this possible?

Where do you want to display this view? in a single parent post or a wordpress page?
How do you setup the post type relationship? one-to-many relationship?

#1849897
Child Post Feed-01.jpg

You can see an example in the attached jpg. I do want this view to be on its own page. Sort of like a dashboard or child post feed. It would show all child posts that are present within the same parent posts where I have contributed a child post.
The post type relationship is one (crowd) to many (contributions).

#1850443

I assume it is a WordPress page:
https://toolset.com/wp-content/uploads/2020/11/1849897-Child_Post_Feed_01.jpg

If it is, you can try these:
1) Create a WP page, display below nested views
2) Grand-parent post view:
- Query posts of parent post type
- In view's loop, display below Parent post view
3) Parent post view:
- Query posts of child post type
- Filter by:
a) Post's author is current logged in user
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/
b) Post relationship between "parent post type" and "child post type"
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items
- In view's loop, display a content template shortcode, and set the item attribute value as parent post:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
@{relationship-slug}.parent
4) In above content template, display a child post view:
- Query posts of child post type
- Filter by:
Post relationship between "parent post type" and "child post type"
- In view's loop, display below child post information

#1851145

I set it up but the pages just shows "no items found" for all child posts on the site.

I am not sure where to put the item attribute... Here is what I have in the Parent Post view loop editor (#3):

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
      [wpv-item name="@{crowd-contribution}.parent"]
		[wpv-post-body view_template="loop-item-in-latest-parent-view"]
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

I also tried:
1. create a child view with a count for all of my child posts
2. create a parent view with a count of parent posts that only shows parent posts where a child post is greater or equal to 1 from view #1
3. create another child view that only shows child posts if a parent post exists in view #2

But it had the same result.

#1853037

Please provide a test site with the same problem, also point out the problem page URLs and view URLs, I need to test and debug it in a live website

#1857323

I have done below modifications in your website:
1) Create a post view "Latest child view 2":
hidden link
- Query "Contributions" posts
- Filter by:
Select posts in a Crowd Contributions relationship that are a related to the current post in the loop.

2) Edit the view "Latest Parent View":
hidden link
- in section "Query Filter", change the filter to:
Select posts in a Crowd Contributions relationship that are a related to the current post in the loop.
In your case, it needs "post in the loop", it is not current page/post
- in section "Loop Editor", display the content shortcode with item attribute:
[wpv-post-body view_template="loop-item-in-latest-parent-view" item="@crowd-contribution.parent"]
- in section "Loop item in Latest Parent View", display above view "Latest child view 2" shortcode:

Crowd: [wpv-post-link]
<hr />
Child Contributions:
[wpv-view name="latest-child-view-2"]

Please test again, check if it is fixed, thanks

#1859461

My issue is resolved now. Thank you!

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