laryn's picture

I want to remove the author name/link on search results listings:

Accepted answer

Thanks to @bwpanda on Zulip chat, the following code in the theme's template.php file does what I need:

/**
 * Overrides template_preprocess_search_results().
 */
function [THEME]_preprocess_search_results(&$variables) {
  foreach ($variables['search_results'] as &$result) {
    $result['info'] = $result['info_split']['date'];
  }
}

 

Most helpful answers

It's easier to take the file search-results.tpl.php from
/core/modules/search/templates
place it in your theme /templates folder
and edit it as you need.

Comments

Thanks to @bwpanda on Zulip chat, the following code in the theme's template.php file does what I need:

/**
 * Overrides template_preprocess_search_results().
 */
function [THEME]_preprocess_search_results(&$variables) {
  foreach ($variables['search_results'] as &$result) {
    $result['info'] = $result['info_split']['date'];
  }
}

 

Is it  possible to enable search index in display mode  for page, for example it would be on /admin/structure/types/manage/page/display and configure to not show author and date info?

It's easier to take the file search-results.tpl.php from
/core/modules/search/templates
place it in your theme /templates folder
and edit it as you need.

thank you, that is very helpful!