Skip to content

Instantly share code, notes, and snippets.

@liam-lime
Created February 6, 2019 10:43
Show Gist options
  • Save liam-lime/de535e1636757a3b43970a98f4fa8433 to your computer and use it in GitHub Desktop.
Save liam-lime/de535e1636757a3b43970a98f4fa8433 to your computer and use it in GitHub Desktop.
WP Filter: Add “time ago” time display at the end of each post
<?php
add_filter( 'the_content', 'wpcandy_time_ago' );
function wpcandy_time_ago ( $content ) {
$content .= "
" . __( 'Posted ', 'wpcandy' ) . human_time_diff( get_the_time('U'), current_time('timestamp') ) . __( ' ago', 'wpcandy' );
return $content;
} // End wpcandy_time_ago()
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment