Hide author from search results | Community
Skip to main content

Hide author from search results

  • March 26, 2015
  • 7 replies
  • 0 views

Quick little script to hide the author from search results using JS:

$('.search-result-meta').each(function() {

var newSearchMeta = $(this).html();

newSearchMeta = "\n    written " + newSearchMeta.substring(newSearchMeta.indexOf("<time"));

$(this).html(newSearchMeta);

});

If you're working with a multilingual Help Center, just add IF/ELSE statements for each variation.

7 replies

  • March 30, 2015

Thanks for the tip, Andrea!


  • April 15, 2015

Hello, what if I want to remove that entire line, including the date it was last written and its location?


  • April 16, 2015

Hi Scott,

You can simply add the following line to your CSS:

.search-result-meta { display: none; }


  • May 18, 2015

I am not sure where to add these things. Between which lines or elements? I have tried pasting this code in several locations and hitting Preview, but it doesn't cause the author's name to disappear.


Hi,

is this js code still vaild after 5 years ?

Is it possible to know right position of css line to remove all content ?

 

Thanks a lot !

 

Cheers


Sumita
  • July 14, 2020

Hey Andrea Villa

Can you please elaborate on which thing you want to hide on the search result template, so that I will provide you exact solution to your problem.

Thanks 

Jay 


  • July 16, 2020

@Andrea Villa

[Note that this comment is valid only if your theme uses unified search results, meaning that your search results have a column on the left where you can specify whether you want to search all types, articles, or the community.]

If you want to hide the author's name, you can add the following code to style.css:

.search-result-meta-name {
display:none;
}

However, since the author's name is followed by a bullet and the date, you probably also want to remove the bullet and padding from before the date. To do this, you need to locate the lines in style.css that reference .search-result-meta-time::before and contain content: "\2022" and padding-left. They should look like the following, although they might not be an exact match: 

.search-result-meta-time::before, .search-result-meta-count::before {
display: inline-block;
content: "\2022";
speak: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
}

[dir="rtl"] .search-result-meta-time::before, [dir="rtl"] .search-result-meta-count::before {
padding-left: .3125rem; /* 5px */
}

You then need to remove .search-result-meta-time::before from the lines so that they look like this:

.search-result-meta-count::before {
display: inline-block;
content: "\2022";
speak: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
}

[dir="rtl"] .search-result-meta-count::before {
padding-left: .3125rem; /* 5px */
}

Please let me know if you have any questions.