In a teaser of a content type, how do you change the text for the "read more" link button?
Asked
Active
Viewed 2,340 times
1 Answers
1
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).
<?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';
}
?>

Derek
- 3,438
- 1
- 17
- 35
-
That was the basic fix. What I did was just go to my www dir and grep -r "Read more" and for me it was located in modules/node/node.module Then I made a copy of the file and changed it in there to "Load more" for my needs: if ($view_mode == 'teaser') { $node_title_stripped = strip_tags($node->title); $links['node-readmore'] = array( 'title' => t('Load more about @title', array('@title' => $node_title_stripped)), 'href' => 'node/' . $node->nid, 'html' => TRUE, 'attributes' => array('rel' => 'tag', 'title' => $node_title_stripped), ); } – seizethecarp Feb 23 '18 at 21:43