WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] "mark" new posts as "NEW"? (4 posts)

  1. arthurdent2003
    Member
    Posted 3 years ago #

    Hi!

    Is there any easy way to mark a post as new (ie: image appears "new")?

    I have a post and it should be marked as "New" for three days?

    Must be something with a Date > < I think. Maybe someone has an answer?!

    Thank you!

    AD

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    you could add a small function to functions.php of your theme;
    example:

    function newly_posted() {
    global $post;
    $now = date('U'); $published = get_the_time('U');
    $new = false;
    if( $now-$published  <= 3*24*60*60 ) $new = true;
    return $new;
    }

    and in your template, use:

    <?php if( newly_posted() ) :
    /*output whatever */
    endif; ?>

    http://php.net/manual/en/function.date.php

  3. arthurdent2003
    Member
    Posted 3 years ago #

    Hey alchymyth,

    sweet - I gonna try this one - thank you very much!

    AD

  4. arthurdent2003
    Member
    Posted 3 years ago #

    Worked for me - thank you alchymyth!!! :)

Topic Closed

This topic has been closed to new replies.

About this Topic