[Resolved] Additional tagging of CPT pages with specific taxonomies to make my text search
This thread is resolved. Here is a description of the problem and solution.
Problem:
I want to have a search function on the home page of my website, like Google's search box. This search will only deliver back results for pages under the custom post type 'Therapies for ...'.
So a client lands on my website on the home page (or if I choose to put this on other pages, and then they can search for help for a specific 'issue' which might be 'anxiety' or it might be 'panic' or it might be bereavement or one of a few hundred issues that I have or will have written CPT for.
Now at the moment I have created a trial search function on the following page:
now you will see that there is both a drop down box which pulls all the pages I have currently written in the CPT 'Therapies for' but eventually there will be a few hundred there and this is both 'too many' to have a drop down for but also it is much easier for a client to search for 'Therapy for an affair' and get back say a 3 results that might be relevant.
However at the moment the client has to be very exact in what they type into the search box as the search only pulls exact matches. If a client put in therapy to recover from someone cheating on me ... there is no result returned.
I want to be able to tag individual CPT pages for the 'Therapies for' CPT with relevant 'tags' so that if a client searches for 'affairs' or 'betrayal' or 'infidelity' or 'Cheating' then the page on 'affairs will be returned.
Is there any documentation that you are following?
I have successfully created the search following your lessons
Is there a similar example that we can see?
not that I've found but like I said I want it to be a simple search box that looks at say the 'title' or 'tags' and delivers back results if one or more of the words entered int he search box is searched for. Solution:
In this case, what might work for you is the integration between Toolset and the plugin Relevanssi: https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/
In this scenario, I’m afraid that it is the best workaround we can offer. For example, you could create some custom fields that would be responsible for the keywords you have mentioned, and then index those fields with the Relevanssi plugin, in order to make a search based on them.
This support ticket is created 2 years, 1 month 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Tell us what you are trying to do?
I want to have a search function on the home page of my website, like Google's search box. This search will only deliver back results for pages under the custom post type 'Therapies for ...'.
So a client lands on my website on the home page (or if I choose to put this on other pages, and then they can search for help for a specific 'issue' which might be 'anxiety' or it might be 'panic' or it might be bereavement or one of a few hundred issues that I have or will have written CPT for.
Now at the moment I have created a trial search function on the following page:
hidden link
now you will see that there is both a drop down box which pulls all the pages I have currently written in the CPT 'Therapies for' but eventually there will be a few hundred there and this is both 'too many' to have a drop down for but also it is much easier for a client to search for 'Therapy for an affair' and get back say a 3 results that might be relevant.
However at the moment the client has to be very exact in what they type into the search box as the search only pulls exact matches. If a client put in therapy to recover from someone cheating on me ... there is no result returned.
I want to be able to tag individual CPT pages for the 'Therapies for' CPT with relevant 'tags' so that if a client searches for 'affairs' or 'betrayal' or 'infidelity' or 'Cheating' then the page on 'affairs will be returned.
Is there any documentation that you are following?
I have successfully created the search following your lessons
Is there a similar example that we can see?
not that I've found but like I said I want it to be a simple search box that looks at say the 'title' or 'tags' and delivers back results if one or more of the words entered int he search box is searched for.
I have just learned how to assign 'tags' and 'categories' to the individual CPT posts so I now know how to 'tag' posts with other keywords that I think could then me used to help create a more usable search - adding the options that poeple might search for e.g. If someone was searching to find a page about Abusive Relationships and used the term 'Domestic Abuse' then I have added a tag to the page called 'Abusive Relationships Counselling' and I'd like the search box to understand that 'Domestic Violence' or 'DV' or 'Intimate Partner Violence' should all return the same CPT post on Abusive Relationship Counselling.
Wasn't sure if 'categories' would also help ... but thought that 'tags' was more likely to.
- first, add a custom search filter to your View: hidden link
- then, choose the ‘Text search (title and content)’ option: hidden link
- also, the CPTs content should contain the keywords you have mentioned
For example, if we search for ‘Domestic Abuse’, no items are found. However, the ‘Abusive Relationship Counselling’ post has this specific word on its content.
Therefore, if you use the custom search filter referred above, you should be able to get the search results showing the posts with the keyword that was searched (that, emphasizing again, should be inserted into the post content).
I hope that I was able to clarify it for you. Please let me know if this explanation solves the question. Thanks!
You see out of the hundreds of pages that I will be writing on all the various 'emotional issues' that humans encounter, many of those pages 'content' will contain these words as part of the natural content ... So although a client who is suffering from say a bereavement of their partner or loved one and the most relevant page for them will be the page all about 'bereavement counselling' there will be many many other pages that may refer to 'bereavement' or 'death' or 'grief' for example if I was writing a page on 'Depression counselling' then in that page I might mention reasons for depression or causes and this might, in passing be 'following the death of someone' or on a page about 'PTSD (Post Traumatic Stress Disorder' I might be talking about past occurrences such as witnessing someone dying ... but only as part of the content
So if I were to use the option of search and return results from title AND content then the client would be faced with 20,30, 100 results all because the content happened to reference that word as a part of the content.
That's why I want to only search and return from the post title and or 'tags' because then the search results will be specific and accurate and useful.
So that although many many pages will contain the word 'bereavement' or 'death' or grief' in the content (in passing) the page that the client would find most useful and that I want to be delivered back would be 'Bereavement Counselling in London'. That's why I only want to search and return results for either post title AND tags or if possible just 'Tags' ... that way I can accurately label the pages and control what the search results will return.
In this scenario, I’m afraid that it is the best workaround we can offer. For example, you could create some custom fields that would be responsible for the keywords you have mentioned, and then index those fields with the Relevanssi plugin, in order to make a search based on them.
Anything beyond that is necessary to configure it with some code customization. At this point, it would be outside from the scope of this support forum but we recommend that you check our contractors page: https://toolset.com/contractors/
As always Toolset offers efficient and really useful advice and support, they understand the issue being described and get to the nub of the matter ... so impressive.
Regarding my issue, as it happens I had already investigated Relvanssi as an option but didn't realise how well it would incorporate with Toolset and it has now allowed me to build a really accurate search system on my site that I know will be super helpful to the end user.
Just in case others are wondering what I did to make the search work for me.
First I built all of my issues pages as 'CPT' so that I could specify that the search should only look at those CPT and content and custom fields. So the CPT 'Therapists in London' are not being searched and no results will be delivered back from their content.
When building the fields section for the CPT 'Therapy for' I added 2 specific fields that aren't seen on the visible webpage but can be indexed by Relevanssi, these two fields are 'search terms' and here I type in all the different specific synonyms that the issue page might be searched for e.g. For a page on bereavement counselling I listed 'death, grief, dying, died, passed, grieving, etc etc ... so that when a search is done for someone looking for advice on 'coping with the grief of the loss of my husband' or something like that ... the most relevant page will be returned because Relevanssi is not searching the content of the main CPT (where the words death or grief or loss or other common terms might also be used with regard to whatever issue that other CPT page is about)
The second custom field I built was the 'snippet' that could then also contain keywords but also would appear neatly as part of the search results using Toolset to dynamically pull it in.
I have a lot of writing to go, but having tested it out I now can focus on all the writing and know I have all the custom fields I need to build a really useful directory that can be searched and returns pin point accurate results.
Thanks Toolset, I really value the power of the system and the support.