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
March 14, 2023

Hi Louise Moghaddam, :)

 

you can try this, check article and then hide that from search results page:

$(".results-list-item-link:contains(What are these sections and articles doing here?)").parent().parent().hide();

$(".results-list-item-link:contains(What are sections?)").parent().parent().hide();

$(".results-list-item-link:contains(What are categories?)").parent().parent().hide();

 

Thanks

Thank You
Louise13
Louise13Author
March 14, 2023

Thanks Ifra, sorry, I don't understand what you mean. Could you outline the exact steps please? Many thanks!

Ifra
Contributor
March 14, 2023

Loiuse, the given code is 

$(".results-list-item-link:contains(What are these sections and articles doing here?)").parent().parent().hide();

 

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.

$(".results-list-item-link:contains(What are these sections and articles doing here?)").parent().parent().hide();

$(".results-list-item-link:contains(What are sections?)").parent().parent().hide();

$(".results-list-item-link:contains(What are categories?)").parent().parent().hide();

 

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.

Thank You
Louise13
Louise13Author
March 16, 2023

It's worked! Thank you for helping Ifra, apologis for being such a luddite!!

September 18, 2023

Hi @ifra.

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.

Ifra
Contributor
September 18, 2023

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.

$(".sidenav-subitem.filter-name:contains(General)").parent().parent().hide();

var _x = $(".breadcrumbs > li > a:contains(General)").parentsUntil(".search-result-meta-container").parent().parentsUntil("article").parent();
$(_x).parent().hide();

 

Hope it is worked for you I just tried.

Thanks :)

 

Thank You
September 19, 2023

Thanks very much @ifra!
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.

Ifra
Contributor
September 19, 2023

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.

Thank You
September 21, 2023

Hi @ifra,

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:

$(".results-list-item-link:contains(Approvals)").parent().parent().hide();

Can you assist me?

Ifra
Contributor
September 21, 2023

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

 

 

Thank You