Restricting search results | The place for Zendesk users to come together and share
Skip to main content
Louise13
March 13, 2023
Question

Restricting search results

  • March 13, 2023
  • 27 replies
  • 129 views

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?

 

27 replies

Ifra
Contributor
September 27, 2023

Ash,

What's your theme name? because there may be different class names. you can try this class:

$(document).ready(function(){
  $(".search-result-title a:contains(Approvals)").parentsUntil("ul").hide();
});


Note: Remove Approvals from JS code, write your article title here, then test.

 

 

Thank You
Ifra
Contributor
September 27, 2023

Tobias Grønbæk Melander, I'm glad that it worked you!

Thank You
Newcomer
September 28, 2023

@ifra

Theme: Flatrock + Alerts - v2

Tried with you suggestion but it didn't work. :(

November 9, 2023

@ifra Hi! Any thoughts on @⛱️ashley's post? We're still stuck on this

Ifra
Contributor
November 9, 2023

@michael183

this is my code snippet

$(document).ready(function(){
  $(".search-result-title a:contains(Approvals)").parentsUntil("ul").hide();
});

 

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

 

Thank You
December 7, 2023

Hi! @ifra,

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?

January 11, 2024

Hi @ifra,

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