Skip Navigation

[Resolved] Create search page that allows filtering/search of post reference

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

Last updated by richardM-13 1 year, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2652253

1. We are trying to build a search page where users can filter on custom post details AND on a second post type that is connected by a many-to-many relationship.

In more detail - We have created a custom post type 'CLINIC' with a few custom fields. Then we have a second custom post type: 'DOCTOR'. A CLINIC can have one or more DOCTORs. This is specified by a many to many relationship. We have successfully built a search page using a View with the following filters:
- Relevanssi text search (can search CLINIC text content)
- City (CLINIC custom field)
- Province (CLINIC custom field)

However, we'd like two more options for users and have not been able to implement these:
- text search to also include DOCTOR names
- dropdown of DOCTOR names

2. In terms of documentation, have reviewed:
https://toolset.com/forums/topic/filtering-view-by-post-reference-field-not-working/
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

3. I'm unaware of a similar example.

4. The page is here: problem URL deleted as requested
Thank you!

#2652597

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I checked the problem URL you shared and I see you added the text search to search - Relevanssi text search (can search CLINIC text content). But you will have to add search button as you can not perform text search without search button.

Normally - you can only add frontend filters (custom search filter) to your view with taxonomy/custom fields which are attached to your post type to which your view is set to query.

For example,
- You have post type X where you assign taxonomy "color" and custom fields (min,max)
- You have post type Y where you assign taxonomy "years" and custom fields (name,surname)

So, if you want to create a custom search for post type X, you can only add frontend filters for taxonomy "color" and custom fields (min,max). You can not build a custom search by adding taxonomy "years" or custom fields (name,surname) as these taxonomy/custom fields are belongs to post type Y.

You should be able to add dropdown for doctor post names by adding the related post filter:
- https://toolset.com/documentation/legacy-features/views-plugin/how-to-filter-by-related-posts/

If you can share admin access details and once I see your structure I will be able to guide you in the right direction.

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

#2653271

Minesh
Supporter

Languages: English (English )

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

I've removed the URL from your initial post. Please let me know if you require further assistance.

#2653391

Hi Minesh,

Thanks for removing the URL.

We will make your suggested edit but in the meantime, now that you have admin access, have you had a chance to login and check structure to make sure everything is correct?

Thanks again,

Richard

#2653523

Minesh
Supporter

Languages: English (English )

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

As you can see with your page now: hidden link

I've added the post relationship frontend filter to your view to filter the Doctors:
- hidden link

Can you please check and let me know if it works as expected.

#2653785

Hi Minesh,

Nice! Thank you. The doctors drop down works exactly as expected.

How do we make it so that users can enter a doctor's name (e.g. 'smith') into the search field and then find that doctor?

Thanks again!

Richard

#2653955

Minesh
Supporter

Languages: English (English )

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

We can not add Doctor text search as the view you are using is set to query the post type 'CLINIC'.

But as you already have doctor dropdown I wonder why you even need that. But You should eliminate that requirement as its not possible.

#2654181

Hi Minesh,

That makes sense. Thanks again for all your help. Much appreciated.

We'll remove that requirement and you can close the ticket.

Best,

Richard