WordPress Question:
How to use time ago function on wordpress posts?
Answers:
Answer #1<!---------------add code in function.php ------------------>
<?php
add_filter( \'the_content\', \'time_ago\' );
function time_ago ( $content ) {
$content .= \"
\" . __( \'Posted \', \'test\' ) . human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . __( \' ago\', \'test\' );
return $content;
}
?>
<?php
add_filter( \'the_content\', \'time_ago\' );
function time_ago ( $content ) {
$content .= \"
\" . __( \'Posted \', \'test\' ) . human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . __( \' ago\', \'test\' );
return $content;
}
?>
Answer #2Please remove all '/' this.
Previous Question | Next Question |
How to create plugin for wordpress? | What is WordPress? |