WordPress.org

Forums

Highwind
Post Modified Time (3 posts)

  1. X-Raym
    Member
    Posted 12 months ago #

    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 ! :)

  2. X-Raym
    Member
    Posted 11 months ago #

    no more success with :

    http://willrees.com/2013/06/show-the-latest-update-time-and-date-for-a-wordpress-page-or-post/

    =/

    any idea ?

  3. X-Raym
    Member
    Posted 11 months ago #

    Did it !

    actually it was "quite" simple, i just need to learn more about my php synthax ^^

    here is the code !

    // 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"><?php the_time( get_option( 'date_format' ) ); ?></time>
    			<?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');?>" class="post-modified-date"><?php the_modified_time( get_option( 'date_format' ) ); ?></a></time>
    <?php
    endif;
    ?>

Reply

You must log in to post.

About this Theme

About this Topic