Drupal 7: change "read more" on content type teaser

2.3k Views Asked by At

In a teaser of a content type, how do you change the text for the "read more" link button?

1

There are 1 best solutions below

1
Derek On

Override the node output by placing this code in your theme's template.php file (replacing with YourThemeName, YourContentType and NewReadMoreText with your theme name and desired read more text).

Source

<?php
// Preprocess variables for node.tpl.php.
function YourThemeName_preprocess_node(&$variables) {
  // Let's get that read more link out of the generated links variable!
  unset($variables['content']['links']['node']['#links']['node-readmore']);

  // Now let's put it back as it's own variable! So it's actually versatile!
  if ($variables['type'] == 'YourContentType') {
  $variables['newreadmore'] = t('<span class="YourContentTypereadmore"> <a href="!title">NewReadMoreText</a> </span>',
      array('!title' => $variables['node_url'],)
   );
  } else {
      $variables['newreadmore'] = t('<span class="newreadmore"> <a href="!title">Read More </a> </span>',
      array('!title' => $variables['node_url'],)
   );
  }

  $variables['title_attributes_array']['class'][] = 'node-title';
}
?>