Reputation: 53
I want to display the time when i modified my articles on the wordpress blog. I tried to find the code, and here what i found
function wpb_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('F jS, Y');
$updated_time = get_the_modified_time('h:i a');
$custom_content .= '<p class="last-updated">Updated on'. $updated_date . ' at '. $updated_time .'</p>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );
but i don't really know how to apply it to my themes, the code for displaying published time one my theme is like below
<?php if( ! empty( $mts_options["mts_{$section}_headline_meta_info"]['date']) ) { ?>
<span class="thetime updated"><i class="fa fa-clock-o"></i> Published on <span itemprop="datePublished"><?php the_time( get_option( 'date_format' ) ); ?></span></span>
<?php } ?>
and i trid to modified the code to this
<?php if( ! empty( $mts_options["mts_{$section}_headline_meta_info"]['date']) ) { ?>
<span class="thetime updated"><i class="fa fa-clock-o"></i> Published on <span itemprop="datePublished"><?php the_time( get_option( 'date_format' ) ); ?></span> Updated on <span itemprop="dateModified"><?php get_the_time( get_option( 'date_format' ) ); ?></span></span>
<?php } ?>
i'm new on php..can anyone help? btw im using yosemite themes by mythemeshop
Upvotes: 0
Views: 278
Reputation: 4055
Your don't need the first set of code (the filter hook).
Print out the modified time like this: the_modified_time( get_option( 'date_format' ) )
Upvotes: 1