Site logo

Archived topic

Add current date to homepage & category pages

17 replies · Started by oge on September 20, 2019

Viewing posts 16–18 of 18

Just to be clear do you want the date in the Title meta tag found in the <head> of your site?

Yes

You can try this filter:

function custom_theme_titles( $titleparts ) {
    $pagetitle = $titleparts['title'];
    $date = date('l jS F Y');
    $sep = " | ";
    $titleparts['title'] = $pagetitle.$sep.$date;
    unset( $titleparts['site'] );
    return $titleparts;
}
add_filter( 'document_title_parts', 'custom_theme_titles', PHP_INT_MAX );

Just to let you know Yoast used to include currentDate variables in there meta editor - there now deprecated and they advise against this practice.

This archived topic is closed to new replies.