Page 1 of 1

This code defines old posts as all articles published at least one year ago.

Posted: Mon Jan 06, 2025 8:55 am
by shaownhasane
Use blocks to add last modified information
You can also create a last updated date notification gansu phone number using custom CSS. In the previous screenshot, we used the following custom CSS.


// Check to see if a post is older than a year
if((date('U')-get_the_time('U')) > $time_defined_as_old) {

$lastmodified = get_the_modified_time('U');
$posted = get_the_time('U');

//check if the post was updated after being published
if ($lastmodified > $posted) {

// Display last updated notice
echo '<p class="old-article-notice">This article was last updated ' . human_time_diff($lastmodified,current_time('U')) . ' ago</p>';

} else {
// Display last published notice
echo '<p class="old-article-notice">This article was published ' . human_time_diff($posted,current_time( 'U' )). 'ago</p>';

}
}
Hosted by WPCode and
One-click use in WordPress

Next, check to see if the post is older than a year. If so, please check if the post has been updated since it was published. It then displays alerts based on these checks.

This is what an old and never updated post looks like on our demo site.

Latest updates to old posts
This is what the old publication looked like, but updated after publication.

An old post, never updated
We customized the old post notification using the following custom CSS.