Skip Navigation

[Resolved] using search to search for everything related to a post

This support ticket is created 4 years, 8 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 15 replies, has 2 voices.

Last updated by BrandenT2154 4 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#1596603

I have created a post type called 'reps' which contains multiple fields, a repeatable field group, and a many-to-many relationship to 'manufacturers' with an intermediary post type.

here is an example of a rep: hidden link

You can see at the bottom of the page that the 'rep' is related to many manufacturers like 'Eaton'

I want to build a search so that when you search for "Eaton" this rep is displayed. Additionally, if you search for "Variable frequency drives." which is the data contained in the intermediary post, this rep is displayed.

however, when i am building a search form on this page hidden link it seems like i can only search by one field at a time. is that really true? is it possible to search more than one field at a time, and only display related results of a post of a particular type?

temp login link: hidden link

#1598011

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Branden,

Thank you for getting in touch.

I think for this It would be best for me to have a look at your setup through the backend before providing an explanation here.

As it is possible to have your search as you have it. You shouldn't be restricted to search with 1 field at a time.

I will enable the private fields so that you can provide me with the site's credentials.

Thanks,
Shane

#1598021

you can just clik on the link in my first post to see the back end

temp login link: hidden link

#1599497

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Branden,

Thank you for the patience.

This issue has been resolved. The issue is that because the relationship fields are Depended then they must be placed in the correct order.

What this means is that the user must first filter for the Manufacturer and then for the intermediary post. What was essentially needed is for you to add the manufacturer filters first and then add the intermediary filters.

If you check on your post now you should see the filters working.

Please let me know if this helps.

Thanks,
Shane

#1599513

hi, no that's not exactly what i was looking for.

Question part 1:

one example is "Variable frequency drives." you will see that this phrase appears in an intermediary post field here hidden link I want it so that when someone searched for "Variable frequency drives." the rep "delren" should dispaly.

for context, Delren is a rep that sells these "Variable frequency drives." and someone might be looking for "Variable frequency drives." so they would want to search for "Variable frequency drives." and find a rep who sells them.

Question part 2:

but my larger question is i want a search field that accomplishes the above-described situation while also allowing the user to use the same search field to search for text in other post custom fields. for example if that same search field could be used to search for Rep's titles, or manufacturers titles, that would be ideal. the idea is to have a 'search for everything' field. the user could type anything into that field. The search results would only displays reps that are in any way related to the search term, albeit directly via fields in the rep's post, or intermediary post fields, or relationships

#1599605

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Branded,

Thank you for the clarity.

Let me see how best I can assist you with this.
Question part 1:

So what you essentially want here is to filter by fields that are NOT on the Rep CPT. Unless the field that you want to filter by is a custom field on the Rep CPT then you are not able to filter the posts by it.

Given that the field that holds "Variable frequency drives." is not on the Rep CPT itself then you are not able to filter the reps by this.

Question Part 2:
" for example if that same search field could be used to search for Rep's titles, or manufacturers titles, that would be ideal. the idea is to have a 'search for everything' field. the user could type anything into that field."

Here is similar to my answer in question 1 above. The search fields will be limited to the post type that the view is displayed. So if you have a text search field for the Post Title it will only search though the Rep's titles , not manufacturers or any other related CPT.

I hope this clarifies your questions for you. There are some limitations but as a workaround for the "Variable Frequency Drives" option. You can just add that custom field directly to the Rep CPT itself. So when creating a rep you can select the option rather than having it in the Intermediary CPT.

Please let me know if this helps.
Thanks,
Shane

#1599807

can i make a video so that hopefully i better explain this?

hidden link

it seems like it must be possible, they are related after all.

#1599999

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Branded,

Thank you for the video, however as mentioned previously Only fields that are On the Rep Post type can be added to a filter for Reps.

This means only fields from this field group below.
hidden link

If the fields are in a Post relationship to the Rep CPT or in a Repeatable field group then you are not able to filter by these fields.

There is an exception for the Related Posts because we have a dedicated Relationship filter for this but for the related custom fields that are in other relationships then we are not able to filter for those.

Hopefully i'm able to clarify for you.

Essentially what you are trying to achieve is Not possible with our Blocks or Views plugin. All the fields that are being searched for must be assigned directly to the CPT you are searching through.

Thanks,
Shane

#1600005

thank you so much for that explaination. and thank you for sticking through this with me.

I have made a new video with a hopeful work around.

essentially i want to display the intermediary posts instead so people can search by those. but i cant figure out how to display related fields in the loop

hidden link

#1600043

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Branden,

It would be possible if you created a Reps view and nest it within the Intermediary CPT View. Unfortunately given that our Blocks plugin is relatively new not every feature is available at the moment.

This is however possible with our Classic editor where you can create the Intermediary CPT view and then add the reps view inside this.

Essentially what would happen is that you will be filtering the Intermediary CPT by the fields that you want and because the Reps view is nested within the Intermediary CPT view it will display the Title of the Rep based on which intermediary CPT result is returned.

So with Blocks it is not possible to do, however our developers are constantly working on improving the Blocks plugin's functionality.

If you like I can let you know how to enable the classic editor in Blocks so that you can create your view setup. If you want a blocks only solution then it won't be possible.

Please let me know.

Thanks,
Shane

#1602951

thanks, i was able to activate classic and started setting that up.

going back to "If the fields are in a Post relationship to the Rep CPT or in a Repeatable field group then you are not able to filter by these fields." do you think it would be possible to extend the search functionality with PHP? or is it really just altogether impossible?

#1603279

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Branden,

"do you think it would be possible to extend the search functionality with PHP?"

It would be possible however I do not recommend it at all. This is because you will need to construct a highly complex query in order to get the correct data. This would probably involve table joins because of how relationships work and they are spread across multiple tables in the database.

So I would not recommend this method at all.

Essentially you are not able to achieve it.

Thanks,
Shane

#1603403

thanks so much.

one last question on this? i hired a developer so i want to know if they are just spinning their wheels.

my idea was to create a custom field in the 'rep' post type that stores intermediary post data whenever the intermediary post type is updated. so in this case, whenever the 'products' intermediary post field is edited, that information would be added or removed to this 'rep' custom field.

usint this method, the 'rep' will have a field that is searchable by the information I'm after. It would be a bit complicated to get the data to sync every time each intermediary post is updated... but.. but this should work, right?

#1604687

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Branden,

Reading through I would say yes, keeping the data synced will allow the field to be searchable.

So whenever the intermediary CPT is updated with a value then the Parent that this similar field is would need to be updated and maintained.

As long as the data remains synced then you won't have to worry and you can indeed search with this field.

Thanks,
Shane

#1609085

My issue is resolved now. Thank you!