WordPress.org

Ready to get started?Download WordPress

Forums

Highlight recently changed posts? (3 posts)

  1. Adam
    Member
    Posted 1 year ago #

    Hi wonderful WP forum-ers,

    I'm trying to put together what I assume (and hope) is a very simple function, and I'm totally lost.

    I have a list of posts, organized by category, and I want to highlight (in a way that I can style by CSS later) recently changed ones. That is, posts whose last modification date was X-days ago. I've scoured for plugins, and can't find one that does the trick. I know WordPress keeps track of post revisions, so I hope this is entry-level stuff, and I'm just too PHP-challenged to sort it out.

    Please help! Thank you!

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    general idea:

    $days = 4;
    if( (date('U') - get_the_modified_date('U')) <= 86400*$days ) { /*some action or output*/ };

    http://codex.wordpress.org/Function_Reference/get_the_modified_date
    http://php.net/manual/en/function.date.php

    where exactly to use the code, depends on your theme, and the structure of your 'list of posts, organized by category'.

  3. Adam
    Member
    Posted 1 year ago #

    Thanks! This gives me a huge head-start.

Topic Closed

This topic has been closed to new replies.

About this Topic