Recent searches
No recent searches
Restricting search results
Answered
Posted Mar 13, 2023
I want to hide certain articles from my help centre and make them only accessible via a link. I've hidden them from the homepage and the articles lists in sections using the 'isnt helper' but I can't see how to exclude them from search results. Is there a way to do this?
1
27
27 comments
Ifra Saqlain
Hi Louise Moghaddam, :)
you can try this, check article and then hide that from search results page:
Thanks
0
Louise Moghaddam
Thanks Ifra, sorry, I don't understand what you mean. Could you outline the exact steps please? Many thanks!
0
Ifra Saqlain
Loiuse, the given code is
This is my article title in the code which I want to hide on search results page:
What are these sections and articles doing here?
So, you only need to remove my article title and add your article title one by one in the code. I'm doing this for my three articles only.
1). What are these sections and articles doing here?
2). What are sections?
3). What are categories?
you just add the given code to the scritp.js file and replace my article's title with yours which you wanna exclude.
0
Louise Moghaddam
It's worked! Thank you for helping Ifra, apologis for being such a luddite!!
0
Bob Rosenbaum
Hi Ifra Saqlain.
Could the approach described above be adapted for the hiding search results from an entire Category? We have several specific Categories that we want to effectively 'exclude' from all searches.
Thanks for any tips you can provide.
0
Ifra Saqlain
Hi Bob Rosenbaum,
Please see the solutions.
Solution 1:
If you want so then you can set your category 'save as draft' mode then only admin can show that specific category.
Solution 2:
Use this code and replace the category name 'General'. This code will hide the complete Category from search result sidebar and hide articles on the search page.
Hope it is worked for you I just tried.
Thanks :)
0
Bob Rosenbaum
Thanks very much Ifra Saqlain!
Yes, we already use the Draft attribute for some categories, but for others it looks like your code can work well. I am tweaking it slightly to fit the requirements of our Search Results page, as it is a bit different from the Copenhagen theme.
My thanks again for your quick assistance here.
0
Ifra Saqlain
Any time Bob Rosenbaum :)
If there is any issue let me know and you can share URL of your woring theme as well then I can find exact solution for you.
0
Tobias Grønbæk Melander
Hi Ifra Saqlain,
I tried pasting the code above into my script.js and changing the article title, but couldn't get it to work.
It looks like this when put into my Help Center:
Can you assist me?
0
Ifra Saqlain
@Tobias Grønbæk Melander, this code isn't for changing article title.
First you tell me the page name where you want to change article title and tell your current article title then I'll provide the exact solution here.
0
Tobias Grønbæk Melander
Ifra Saqlain,
What I meant is I that I changed the article title from yours to mine, so as to hide the given article from the search results using the solution you provided earlier in this thread.
When trying to use that solution however, it doesn't work. I have also had success in hiding the article from the category and section pages using the 'isnt helper' like Louise.
0
Ifra Saqlain
Tobias Grønbæk Melander,
Use the below code to hide article from search results page, replace my article title (What is the article?) to yours:
I'll work and if not let me know:)
0
Tobias Grønbæk Melander
Hi Ifra Saqlain,
Thanks for returning to me so quickly! :)
I tried the code, but unfortunately it doesn't seem to work either:


Did I put the code somewhere wrong?
Thanks again.
0
Ifra Saqlain
Steps to follow:
i). Add JQuery CDN to your document_head.hbs file.
ii). Add wrap this code inside a function like below:
0
Tobias Grønbæk Melander
Ifra Saqlain
Thanks for the help, but unfortunately it didn't work:


0
Ifra Saqlain
Check your console on preview mode, is there any error?
OR
You can share URL of your theme here then I can figure out the bug and after fixing the bug, you can remove URL by editing your comment.
0
Tobias Grønbæk Melander
There seems to be one yes:
I've mostly been working in a test environment, so as not to break anything in the live version. Can I still share that? Or is it the link to the theme we're using? (Flatrock from Lotusthemes).
0
Ifra Saqlain
Tobias Grønbæk Melander , remove the previous code and use this code, it will definitely work, I have tested and updated yet using Flatrock theme, actually, classes are different that's why the previous code isn't working for you.
0
Tobias Grønbæk Melander
Ifra Saqlain,
Thank you, that helped!
(However only for the newest version of Flatrock it seems, but that's no issue, just noticed it didn't work in one of my test environments).
0
Ashley M
Ifra Saqlain

We are having the same issue when trying to hide this term:
0
Ifra Saqlain
Ash,
What's your theme name? because there may be different class names. you can try this class:
0
Ifra Saqlain
Tobias Grønbæk Melander, I'm glad that it worked you!
0
Ashley M
Ifra Saqlain
Theme: Flatrock + Alerts - v2
Tried with you suggestion but it didn't work. :(
1
Michael Buckley
Ifra Saqlain Hi! Any thoughts on Ashley M's post? We're still stuck on this
0
Ifra Saqlain
Michael Buckley,
this is my code snippet
If it's not working then definitely the class name is different in your theme.
Change this class-name -- search-result-title, in the code, it will definitely work.
i). Go to your search_results_page.hbs file.
ii). Find for search-results-list.
iii). You can see <h2> tag under the list. There is a class, copy that and paste it into the given script code.
In Copenhagen theme, <h2> tag has this class-name so I have added this class-name in my code.
You will have different so remove my class-name and add yours.
Thanks
0
Ogaki
Hi! Ifra Saqlain,
Your code worked on the native search result but the article still shows on "Instant search" result. Is there any way to hide them from Instant search as well?
2
Dganit Rauchwerger
Hi Ifra Saqlain,
I have an article that I want to make unsearchable in the Help Center. People will only be able to access the article with a direct link. I saw previous posts where you provided guidelines on how to implement this.
1. Please confirm that I need to add the code to the script.js file.
2. What is the exact code that I need to add and in what line?
Thank you so much,
Dganit
0