How to theme D7 search results The default search results in D7 seem to include details of the node author, date, number of comments as seen here but I don't want these in my search results.   

I have copied search-result.tpl.php and search-results.tpl.php to my theme file. I have added 

print '&lt;pre&gt;'. check_plain(print_r($info_split, 1)) .'&lt;/pre';


to search-result.tpl.php. The result is here ie showing the array with [user] [date] [comment] etc

What do I need to do to exclude author / date / number of comments from the search results? If it involves my theme's search-result.tpl.php what should be the contents of search-result.tpl.php ?
Copy search-result.tpl.php into your theme folder..


Override above tpl using below code..

&lt;?php

/**
 * @file
 * Default theme implementation for displaying a single search result.
 *
 * This template renders a single search result and is collected into
 * search-results.tpl.php. This and the parent template are
 * dependent to one another sharing the markup for definition lists.
 *
 * Available variables:
 * - $url: URL of the result.
 * - $title: Title of the result.
 * - $snippet: A small preview of the result. Does not apply to user searches.
 * - $info: String of all the meta information ready for print. Does not apply
 *   to user searches.
 * - $info_split: Contains same data as $info, split into a keyed array.
 * - $module: The machine-readable name of the module (tab) being searched, such
 *   as "node" or "user".
 * - $title_prefix (array): An array containing additional output populated by
 *   modules, intended to be displayed in front of the main title tag that
 *   appears in the template.
 * - $title_suffix (array): An array containing additional output populated by
 *   modules, intended to be displayed after the main title tag that appears in
 *   the template.
 *
 * Default keys within $info_split:
 * - $info_split['module']: The module that implemented the search query.
 * - $info_split['user']: Author of the node linked to users profile. Depends
 *   on permission.
 * - $info_split['date']: Last update of the node. Short formatted.
 * - $info_split['comment']: Number of comments output as "% comments", %
 *   being the count. Depends on comment.module.
 *
 * Other variables:
 * - $classes_array: Array of HTML class attribute values. It is flattened
 *   into a string within the variable $classes.
 * - $title_attributes_array: Array of HTML attributes for the title. It is
 *   flattened into a string within the variable $title_attributes.
 * - $content_attributes_array: Array of HTML attributes for the content. It is
 *   flattened into a string within the variable $content_attributes.
 *
 * Since $info_split is keyed, a direct print of the item is possible.
 * This array does not apply to user searches so it is recommended to check
 * for its existence before printing. The default keys of 'type', 'user' and
 * 'date' always exist for node searches. Modules may provide other data.
 * @code
 *   &lt;?php if (isset($info_split['comment'])): ?&gt;
 *     &lt;span class="info-comment"&gt;
 *       &lt;?php print $info_split['comment']; ?&gt;
 *     &lt;/span&gt;
 *   &lt;?php endif; ?&gt;
 * @endcode
 *
 * To check for all available data within $info_split, use the code below.
 * @code
 *   &lt;?php print '&lt;pre&gt;'. check_plain(print_r($info_split, 1)) .'&lt;/pre&gt;'; ?&gt;
 * @endcode
 *
 * @see template_preprocess()
 * @see template_preprocess_search_result()
 * @see template_process()
 *
 * @ingroup themeable
 */
?&gt;
&lt;li class="&lt;?php print $classes; ?&gt;"&lt;?php print $attributes; ?&gt;&gt;
  &lt;?php print render($title_prefix); ?&gt;
  &lt;h3 class="title"&lt;?php print $title_attributes; ?&gt;&gt;
    &lt;a href="&lt;?php print $url; ?&gt;"&gt;&lt;?php print $title; ?&gt;&lt;/a&gt;
  &lt;/h3&gt;
  &lt;?php print render($title_suffix); ?&gt;
  &lt;div class="search-snippet-info"&gt;
    &lt;?php if ($snippet): ?&gt;
      &lt;p class="search-snippet"&lt;?php print $content_attributes; ?&gt;&gt;&lt;?php print $snippet; ?&gt;&lt;/p&gt;
    &lt;?php endif; ?&gt;
  &lt;/div&gt;
&lt;/li&gt;



Clear Cache


Author / date / number of comments from the search results is getting rendered using below code

&lt;?php if ($info): ?&gt;
  &lt;p class="search-info"&gt;&lt;?php print $info; ?&gt;&lt;/p&gt;
&lt;?php endif; ?&gt;


which we removed from above overridden tpl....

You can also remove it using below function in your theme template.php

function YOURTHEME_preprocess_search_result(&amp;$variables) {
  $variables['info'] = '';
}