Post Modified Time
-
Hi !
I want to display the_modified_date next to the_date (in the loop or in single), only if the post was modified, and more than 3 hours after its published time.
I usually use something like this directly on single.php :
<?php define ('DELAY_POST_UPDATE_DISPLAY', 3); if (get_the_modified_date() != get_the_date() || get_the_modified_time('Gi') - get_the_time('Gi') >= DELAY_POST_UPDATE_DISPLAY * 100) : ?> <time datetime="<?php the_modified_time('c');?>"><?php the_modified_time('j F Y \à H:i'); ?></time> <?php endif; ?>
…but for some kind of reason, I don’t succeed to implement it well, either in single.php or using function.php. The modified time appears all the time, even is the post hasn’t be modified. I have to say I’m not a php developer, I don’t know if I did the thing right, but i succeed on three other themes, and not in this one =/
I know i have to modify the highwind_post_date in functions.php. This is how far i get without breaking the theme (and without the “if” statement)
// custom post date and modified time if ( ! function_exists( 'highwind_post_date' ) ) { function highwind_post_date() { if ( ! is_page() && ! is_404() ) { ?> <time datetime="<?php the_time('c');?>" class="post-date"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'highwind' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_time( get_option( 'date_format' ) ); ? ></a></time> <time datetime="<?php the_modified_time('c');?>" class="post- modified-date"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'highwind' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_modified_time( get_option( 'date_format' ) ); ?></a></time> <?php } } }
Can you please help me on this ? ??
Thanks ! ??
- The topic ‘Post Modified Time’ is closed to new replies.