Showing updated date instead of published date

I wanted the post updated date to show instead of the published date. One can use a filter on the get_the_date and limit it to the archives and single posts etc. Not, great, tad misleading, but works for most themes (any that call get_the_date() anyway).

One can also override the theme’s function with a plugin.

Here’s the code if you just want to go the filter method:

<?php //add plugin header
function amr_use_updated_date ($the_date, $d, $post ) {
	if (is_archive() or is_home() or is_front_page() 
		or (is_single() and $post->post_type = 'post')) {
			if ( '' == $d ) 
				$the_date = mysql2date( get_option( 'date_format' ), $post->post_modified );
				$the_date = mysql2date( $d, $post->post_modified );
	return $the_date;

add_filter ('get_the_date', 'amr_use_updated_date', 3, 99);

Overwriting a themes pluggable function without a child theme, using a plugin


At activation time, the theme is loaded before your plugin, but after that the plugin is loaded first, so bracket the function in your plugin in the same way that the theme function is ‘plugged’

if !function_exists('pluggable_theme_function_name') {

function pluggable_theme_function_name () {
code here


One is to use a child theme to overwrite a theme’s pluggable functions. BUT oh switching to a child theme is painful if one has done settings via the theme customizer. One has to re do the settings for the child theme. A better option I thought would be to define my own function to be used instead of the themes. But every time I tried to activate the plugin, it would tell me that the function was already defined. I thought I would have to resort to must-use plugin. Didn’t want to have to do that. I also wasn’t ready to redo my site., I was happy still using twenty-eleven theme.

Then for some reason I put “if ( ! function_exists( ‘twentyeleven_posted_on’ ) ) : ” before my function definition. It shoudn’t be necessary if my function was to be the one, it shouldn’t need that since it had to be defined first.

Lo and behold, then I could activate it, and once past the activation, it would work, I could even remove that line of code, and it would still work. It was only at activation time that the theme’s function was loaded before mine. The little plugin now looks like this:

Plugin Name: amr adjust theme 2011
Author: anmari
Author URI:
Plugin URI:
Version: 1.0

Description: Show 'Updated' and date last updated instead of published date
if (!function_exists('twentyeleven_posted_on')) {
function twentyeleven_posted_on() {

	$post = get_post();
	$the_date = mysql2date( get_option( 'date_format' ), $post->post_modified );
	$the_date_c = mysql2date( 'c', $post->post_modified );
			__( '<span class="sep">Updated on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
		esc_url( get_permalink() ),
		esc_attr( get_the_title() ),
		esc_attr( $the_date_c ),
		esc_html( $the_date ),
		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),