Skip Navigation

[Resolved] Conditional content within a post-type relationship.

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 8 replies, has 2 voices.

Last updated by Minesh 3 months, 1 week ago.

Assisted by: Minesh.

Author
Posts
#2779888
Screenshot 2024-10-30 at 09.09.43.png

Tell us what you are trying to do?
I have a many-to-many post type relationship and am trying to create a header that displays only if posts are within the loop.

What is the link to your site?
You can see it on this page. Lecturer and Location are both post type relationships. I don't have a lecturer related to this post, but the header still shows up. The image attached shows how I set up the loop.
hidden link

#2779894

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

You should try to add conditional block to your view's loop as mentioned with the following Doc and that should help you to resolve your issue.
- https://toolset.com/course-lesson/creating-a-custom-search/#hide-the-search-results-until-the-first-search

#2779902
Screenshot 2024-10-30 at 09.32.37.png
Screenshot 2024-10-30 at 09.32.29.png

Hi, thanks for getting back to me.

That didn't work though. Here's what I did.

#2779914

Minesh
Supporter

Languages: English (English )

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

What if you try to change the condition for your conditional block as per the following screenshot and try to resolve your issue.
- hidden link

You should select "View Shortcodes" and further select the option "Number of Items found in Views" and compare that with greater than sign and static value zero (0).

#2779940
Screenshot 2024-10-30 at 11.08.04.png
Screenshot 2024-10-30 at 11.08.13.png

Still not working. Here's what I did.

#2779952

Minesh
Supporter

Languages: English (English )

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

That is strange.

Can you please share problem URL and send me admin access details and what view you created.

*** 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.

#2779960

Minesh
Supporter

Languages: English (English )

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

Can you please check now:
- hidden link

I've removed the existing conditional block and added the new one with the same conditions shared as before and I can see it working as expected:
- Screenshot:hidden link
- hidden link

#2779961
Screenshot 2024-10-30 at 12.23.45.png

It's not working as expected. Please take a look at the attached screenshot.

I'm supposed to be seeing a header "Lecturers" and a lecturer with his name and photo in the space above "Location". These are only meant to be displayed if there is a lecturer related to this specific course.

#2779983

Minesh
Supporter

Languages: English (English )

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

I see the Course post in backend:
- hidden link

And I see the related Lecture post for the above post is "Mark Bonello Ghio" but when I checked that post on Lecture listing page:
- hidden link

The related Lecture post "Mark Bonello Ghio" is set as draft.

What if you try to publish the "Mark Bonello Ghio" Lecture post and then check:

#2779984

Thank so much!