Skip Navigation

[Resolved] Filter view to show posts that do not have any child relationship

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

Problem:
Filter view to show posts that do not have any child posts, only display parent posts who do not have child

Solution:
You need to create nested views in order to display only parent posts who does not have assigned any child posts.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/filter-view-10to-show-posts-that-do-not-have-any-child-relationship/#post-1310311

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

This support ticket is created 4 years, 9 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by spotlightS 4 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1310231

Tell us what you are trying to do?
I have a Post Type "Report" and then three child post types "Cause", "Action" and "Conclusion" which act as notes for the report.

What I need to be able to do is create a view that filters the reports to show me a list of those that do not have any notes attached (so that they can be followed up)

Is there any documentation that you are following?

https://toolset.com/forums/topic/conditional-output-based-on-post-relationships/ - I looked at this but it does not seem to work in my case (always returns zero) and of course I'm not sure how to use it as a filter.

#1310311

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

So, I've created the following views - you can see how I configured both the views.
=> hidden link
=> hidden link

The parent view is configured as given under:
=> => hidden link

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
     
          [wpv-view name="child-resources" ptitle="[wpv-post-title]"]
		</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]

The child-view with the post relationship filter is configured as given under:
=> hidden link

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
      <li> [wpv-attribute name="ptitle"]</li>	
	[/wpv-no-items-found]
[wpv-layout-end]

Where - as you can see we are cathing the "ptitle" value using the shortcode [wpv-attribute] that we passed from the parent view's loop [wpv-view name="child-resources" ptitle="[wpv-post-title]"].

Then, I've this following test page:
=> hidden link

I can see its working fine. Can you please confirm

#1310327

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Also, I forget to update you that from Toolset => Relationship I've migrated the site to new relationship:
=> https://toolset.com/2018/05/when-if-to-migrate-relationships-in-old-toolset-sites/

#1310329

Thank you - I have changed it a little to work with multiple relationships and it seems to working great - now I just need to display other data within the loop

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