Changing “Submitted by” in Drupal 7

Summary: I want a custom byline on my posts.
Solution: Modify template.php

I did  this for Poligo by modifying the node.tpl.php file. However, I thought I would poke around for another way to do it on The English Farm. I found this way of doing it with template.php. I tried adding this to template.php:

<?php
function yourthemename_preprocess_node(&$vars) {
  $vars['submitted'] = t('By !username on !datetime', array('!username' => $vars['name'], '!datetime' => format_date($vars['node']->created, 'custom', 'F j, Y')));
}
?>

It did not work, at all. I went back to using the node.tpl.php method. That was also not working, I found because of Display Suite. I disabled it on the node type I was working on and went with the node.tpl.php approach. I also read that that way is more in line with Drupal best practice.

No comments yet.

Leave a Reply