Remove "pubdate" attribute from submitted time tag in Drupal 7

278 views Asked by At

Currently when a node or comment is submitted it gets a Submitted text saying "Submitted by user on Wed, 04/01/2015 - 18:07"

The mark-up for this is:

<span>Submitted by *user* on <time pubdate="pubdate" datetime="2015-04-01T18:07:34+0000">Wed, 04/01/2015 - 18:07</time></span>

What I need to do is remove the "pubdate" attribute from the tag because the it is failing on W3C validation.

I have tried to add the following code in my template.php file but had no luck

function ThemeName_preprocess_node(&$variables) {
    $attributes['datetime'] = '<time'.drupal_attributes($attributes) .'>'.$variables['date'] . '</time>';
}

How can I remove the "pubdate" attribute in the Submitted by tag?

1

There are 1 answers

0
harnamc On

Need to hook into "preprocess_node" to access the $submitted variable like so:

function THEME-NAME_preprocess_node(&$variables, $hook) {

$variables['pubdate'] = '<time datetime="' . format_date($variables['node']->created, 'custom', 'c') . '">' . $variables['date'] . '</time>';

$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' =>$variables['name'], '!datetime' => $variables['pubdate']));
}