How can I modify the search results on drupal 7 so that the submitted by author and date doesn't appear?


Try below code in your template.php

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

Or create a template file for search results if not there named "search-result.tpl.php" and add this

<li class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print render($title_prefix); ?>
 <h3 class="title"<?php print $title_attributes; ?>>
   <a href="<?php print $url; ?>"><?php print $title; ?></a>
 <?php print render($title_suffix); ?>
   <div class="search-snippet-info">
  <?php if ($snippet): ?>
    <p class="search-snippet"<?php print $content_attributes; ?>><?php print $snippet; ?></p>
<?php endif; ?>
<?php if ($info): ?>
  <p class="search-info"><?php print $info; ?></p>
<?php endif; ?>

and To remove the author, date and comments count remove or comment out the following lines:

<?php if ($info): ?>
  <p class="search-info"><?php print $info; ?></p>
<?php endif; ?>

and in css

.search-info {
display: none;

Taken answer from this link

| improve this answer | |

You can also completely remove those items instead of just setting display to none, template_preprocess_search_result function processes variables for search-result.tpl.php . So by modifying the template_preprocess_search_result you can limit the varibles sent to search-result.tpl.php. It is the function, use the modified version in template.php

function template_preprocess_search_result(&$variables) {
    global $language;

    $result = $variables['result'];
    $variables['url'] = check_url($result['link']);
    $variables['title'] = check_plain($result['title']);
    if (isset($result['language']) && $result['language'] != $language->language && $result['language'] != LANGUAGE_NONE) {
        $variables['title_attributes_array']['xml:lang'] = $result['language'];
        $variables['content_attributes_array']['xml:lang'] = $result['language'];

    $info = array();
    if (!empty($result['module'])) {
        $info['module'] = check_plain($result['module']);

    if (!empty($result['user'])) {
        $info['user'] = $result['user'];
    if (!empty($result['date'])) {
        $info['date'] = format_date($result['date'], 'short');

    if (isset($result['extra']) && is_array($result['extra'])) {
        $info = array_merge($info, $result['extra']);
    // Check for existence. User search does not include snippets.
    $variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : '';
    // Provide separated and grouped meta information..
    $variables['info_split'] = $info;
    $variables['info'] = implode(' - ', $info);
    $variables['theme_hook_suggestions'][] = 'search_result__' . $variables['module'];

by removing the if (!empty($result['user'])) { and if (!empty($result['date'])) { lines the user and date will be removed.

| improve this answer | |

I installed the "Custom search " module and it was the easiest way. https://www.drupal.org/project/custom_search

| improve this answer | |

You can theme it, change code as you wish, place following code in template.php in your theme root folder.

function YOURTHEME_preprocess_node(&$vars) {

$vars['submitted'] = t('Author: !username, created: !datetime', array('!username' => $vars['name'], '!datetime' => format_date($vars['node']->created, 'custom', 'M d, Y'))); }

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.