Site logo

Archived topic

Share code - Show the publication and the modification post date

2 replies · Started by Alessio Angeloro on May 2, 2022

Viewing posts 1–3 of 3

Hi guys.

I would like to share this feature for those who want to show the published and modified date of a post with a condition.

add_filter( 'generate_post_date_output','aa_add_to_post_date' );

function aa_add_to_post_date( $output ) {

	$published = get_the_date();

	$modified = get_the_modified_date();

	if ($published == $modified){

		return 'Published on ' . $output;  

	} else {

		return 'Published on ' . $output . '· Updated on '.$modified; 

	}

}

Have a nice day,
Alessio

Thank you for sharing this Alessio! :)

Welcome.

I love GP :-)

This archived topic is closed to new replies.