Skip Navigation

[Resolved] Display HTML on parent if /any/ child has a property

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

Problem:

I have two cpts in a many-to-many relationship, Doctor and Office (no intermediate post-type, in case it matters). Most Offices have only one Doctor, though some have 2-4.

I want to display an IMG tag on (and, ideally, filter/prioritise in search) Offices where at least one Doctor has either a checked field or a taxonomy item "Certified Member"

Solution:

In a single "Office" post, you can create a post view:

1) Query "Doctor" posts,

2) Filter by:

- the post type relationship between post type Doctor and Office

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

- post assigned with term "Certified Member"

https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

3) In the "Loop Editor" section, within shortcode [wpv-items-found] ... [/wpv-items-found], display the image cert-flash.png

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found

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

Last updated by Nathan 6 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1149395

Hi,

I have two cpts in a many-to-many relationship, Doctor and Office (no intermediate post-type, in case it matters). Most Offices have only one Doctor, though some have 2-4.

I want to display an IMG tag on (and, ideally, filter/prioritise in search) Offices where at least one Doctor has either a checked field or a taxonomy item "Certified Member"

In psuedocode, the view template for Office will go something like
IF any myDoctors has taxonomy = "certified-member"
img: cert-flash.png
ENDIF

// other Office details...

I've used https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/ to help set up the basic structure, but I'm stuck at how to write the conditional. My wpv-if game is weak 🙂

Help me, Obi-wan, you're my only hope

hugs
nathan

#1149691

Hi,

In a single "Office" post, you can create a post view:

1) Query "Doctor" posts,

2) Filter by:
- the post type relationship between post type Doctor and Office
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
- post assigned with term "Certified Member"
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

3) In the "Loop Editor" section, within shortcode [wpv-items-found] ... [/wpv-items-found]
display the image cert-flash.png
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found

#1149942

That was easy lol. Thanks!