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

September 22, 2023

@ifra

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.

Ifra
Contributor
September 22, 2023

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:

 $(".search-result-title a:contains(What is the article?)").parentsUntil("ul").hide();

 

I'll work and if not let me know:)

Thank You
September 22, 2023

Hi @ifra,

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.

Ifra
Contributor
September 22, 2023

Steps to follow:

i). Add JQuery CDN to your document_head.hbs file.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>


Screenshot for the same:

 

 

ii). Add wrap this code inside a function like below:

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


Screenshot for the same:
Thank You
September 22, 2023

@ifra

Thanks for the help, but unfortunately it didn't work:

Ifra
Contributor
September 22, 2023

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.

 

Thank You
September 22, 2023

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

Ifra
Contributor
September 22, 2023

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.

$(document).ready(function(){
$(".lt-search-result__title a:contains(Approvals)").parentsUntil("ul").hide();
});
Thank You
September 27, 2023

@ifra,

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

Newcomer
September 27, 2023

@ifra

We are having the same issue when trying to hide this term: