• Resolved nehagrover027

    (@nehagrover027)


    Hi,

    I’ve this brand new post: [ redundant link removed ] which doesn’t have any Revisions/updations.
    Still Its showing same date as Updated & Published.
    My code goes like this:

    
    <p><?php if ( function_exists( 'get_the_last_modified_info' ) ) { $updated_date = get_the_last_modified_info(); }
    if($updated_date): echo 'UPDATED: '.$updated_date.' / '; endif; 
    echo 'PUBLISHED: '.get_the_date(); ?></p>
    

    I’ve included the filter:

    
    function override_time_diff() {
        return '86400'; // 86400 seconds i.e. 24 hours, set it according to your need
    }
    add_filter( 'wplmi_date_time_diff_post', 'override_time_diff' ); // for posts
    add_filter( 'wplmi_date_time_diff_page', 'override_time_diff' ); // for pages
    

    but it doesn’t work.
    Can you please help me troubleshoot this.?

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sayan Datta

    (@infosatech)

    Hi @nehagrover027

    Try to use this way:

    if ( function_exists( 'get_the_last_modified_info' ) ) { 
        $original_time = get_the_time('U'); 
        $modified_time = get_the_modified_time('U'); 
        if ( $modified_time > $original_time + 86400 ) { // 86400 seconds i.e. 24 hours, set it according to your need
            echo 'UPDATED: '. get_the_last_modified_info() .' / ';
        }
    }
    echo 'PUBLISHED: '. get_the_date();

    This below snippet is actually not for template tag. It is for the auto inserted last modified date using the_content() filter.

    function override_time_diff() {
        return '86400'; // 86400 seconds i.e. 24 hours, set it according to your need
    }
    add_filter( 'wplmi_date_time_diff_post', 'override_time_diff' );
    add_filter( 'wplmi_date_time_diff_page', 'override_time_diff' );

    Thanks!

    Thread Starter nehagrover027

    (@nehagrover027)

    That worked.!
    Thank you so much.!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter to override Publish date not working’ is closed to new replies.