Skip Navigation

[Resolved] Conditionally hiding parent post based on Child Post conditions

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 simchaH 5 months, 2 weeks ago.

Assigned support staff: Minesh.



A while back, Minesh helped me tackle this, see thread:

I was trying to hide the main loop parent post, if there were no nested children displaying inside of it (connected to it). The code worked perfectly! For some reason I went to check it out and when I do a search as a user on the frontend, I am getting Posts where even if there are no child connections, it is still displaying. Can someone help me figure this out?




Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

With what search you are still see the post with no child? Can you please share problem URL?

The code is universal and should work without any issues, even you confirm that it works but somehow its stopped working you mean for now.

Can you please share all required details with couple of example when its displaying the parent post even no child exists as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.



Languages: English (English )

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

you enter into "Name of Shul" input field the words "boca raton", you will see 2 posts come up. 1 will have child posts inside, and the other one will be empty. (Note that an empty child post will have the words "No shiurim at this location. Add one here" inside of the parent post. This is the generic statement I have displaying for empty Locations).
To fix this issue I've adjusted the code added to "Custom Code" section with code snippet "Only Display Shiur Location with Shiur" and change the following line of code from:

  if(empty($parent_ids) or empty($has_role) ){


 if(empty($parent_ids) or empty($has_role) or empty($found_loc_shiur)){

Another search example is the word "aish" again into the same input field. You will see 4 posts show up. The first 3 are good, they have child posts inside, the last one is empty and should be hidden according to our script.
To fix this issue, this is not the issue form the code I've added but the conditionals you added within the view's loop. I've adjusted the following condition from the following view from:
- hidden link

 [wpv-conditional if="( $(wpcf-contact-role).item(@person-to-shiur.parent) eq 'Maggid Shiur' )"]


[wpv-conditional if="( '[types field='contact-role' option='1' item='@person-to-shiur.parent'][/types]'  eq 'Maggid Shiur' )"]

This change is required because as you can see with the following post, it has been assigned with the three "Contact Role" checkboxes option (Rabbi, Maggid Shiur, Contact)
- hidden link

The following condition is mean to check only one checkbox option checked out of all but you have checked three options n (Rabbi, Maggid Shiur, Contact):

 [wpv-conditional if="( $(wpcf-contact-role).item(@person-to-shiur.parent) eq 'Maggid Shiur' )"]

So, to check specific option out of all checked, we have to change the conditional statement to:

[wpv-conditional if="( '[types field='contact-role' option='1' item='@person-to-shiur.parent'][/types]'  eq 'Maggid Shiur' )"]

More info:

I must say the structure you have is really hard to understand as well as really complex one but happy that every time I found the solution for you and glad that I can assist you with the solutions.


I know it really is complex! I am so appreciative that you were able to help me, and so quickly as well! thank you very much. My issue is resolved now. Thank you!