Display a message on older post — Wordpress

horaciobella

Horacio Bella

2 years ago · 663 views
<?php 
$post_age = date('U') - get_the_time('U');
if($post_age > 63072000) { echo 'This post has more than two years'; } ?>
Raw

Inside the loop, maybe below the title.

Use UNIX date format to set the time: A year (31536000) Six months (15768000) A month (2628000)

Tagged: snippet wordpress
Comments are only visible to Forrst members. Log in or Request an invite.
3 new notifications