I'm trying to show in my WordPress posts the modification date of a post, as long as it has been modified of course.
Searching the net I found this code on StackExchange:
if ( get_the_modified_time( 'U' ) > get_the_time( 'U' ) ) {
echo 'Last updated:' . get_the_modified_time();
}
Adapting it, I have incorporated it like this into my functions.php
:
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter($post_info) {
if ( is_single() ) {
$post_info = 'Por [post_author_posts_link] | Fecha de publicación: [post_date]';
if ( get_the_modified_date( 'U' ) > get_the_date( 'U' ) ) {
//echo 'Last updated:' . get_the_modified_time();
$post_info .= 'Modificado: ' . get_the_modified_date();
}
return $post_info;
}}
The problem is that it always shows the modified date, even though the input hasn't been changed.
How could I tune it up?
Finally, after a series of checks and changes, I managed to get what I wanted. The problem was that they were both
get_the_modified_time()
returningget_the_time()
a String type, so I've captured those values in variables and then proceeded to pass them to typedate
.