• Resolved kalsey

    (@kalsey)


    I’m running a news portal site http://newsview.in and I add the string
    Modified: <?php the_modified_time(‘g:i a’); ?>
    to get the post Modified time, but when I post a new news the post time and modified post are same and I don’t want this. I want

    Show: Published: <?php the_time(‘F j, Y’); ?> , <?php the_time(‘g:i a’); ?>

    If (Post time is equal to Modified time)
    show noting
    else (Modified: <?php the_modified_time(‘g:i a’); ?>)

    Can anybody help me in this if-else program, where the Modified only show when the post is modified not except that

Viewing 7 replies - 1 through 7 (of 7 total)
  • Greetings,
    I found your answer actually already in the WordPress Codex. Here is the conditional:

    if (get_the_modified_time() != get_the_time()) {
    // show modified time
    the_modified_time();
    }

    I found this under “Description” on the following page:
    http://codex.wordpress.org/Function_Reference/the_modified_time

    Good luck,
    Paul

    Thread Starter kalsey

    (@kalsey)

    Nice work Paul its work me like a Charm. I used like this in the Single.php
    <?php if (get_the_modified_time() != get_the_time()) {
    // show modified time
    the_modified_time();
    } ?>

    and its working great, but one more you can do. I need to add this “Modified:” in this condition, because If I place it before the <?php
    it also shown on that post also that don’t had the Modified time. I think understand my query.

    Exmaple
    Your Condition shows
    Published: July 22, 2013 , 6:55 pm | 7:03 pm

    But I need
    Published: July 22, 2013 , 6:55 pm | Modified: 7:03 pm

    IF I put the “Modified:” before php I get this on that post which don’t had the modified time
    Published: July 22, 2013 , 6:52 pm | Modified:

    Sure, just add the “Modified” inside the conditional:

    <p>Modified: <?php the_modified_time(); ?></p>

    Glad this helps out.
    Take care,
    Paul

    Thread Starter kalsey

    (@kalsey)

    Where to put in this condition

    <?php if (get_the_modified_time() != get_the_time()) {
    // show modified time
    the_modified_time();
    } ?>

    <?php
    if (get_the_modified_time() != get_the_time()) {
    // show modified time
    ?>
    <p>Modified: <?php the_modified_time(); ?></p>
    <?php
    }
    ?>

    The above is one way to do it.
    Paul

    Thread Starter kalsey

    (@kalsey)

    Nice coding Paul work like a charm

    THANKS A LOT

    Thread Starter kalsey

    (@kalsey)

    Resolved

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Show Post Modified Time if Different from Post time’ is closed to new replies.