I want to create a code snippet for expiration of post after x days from the post published date, I tried with this code but I always displays the true condition, what am I doing wrong?
$pfx_date = get_the_date('d/m/Y');
$datacorrente = date('d/m/Y', strtotime("-5 days"));
if ( $pfx_date <= $datacorrente ) {
echo 'post expired';
} else {
echo 'post open';
}
"-5 days" is the x days variable after the post is expired.
$expired = ( ( time() - strtotime(get_the_date('Y-m-d H:i:s')) ) / DAY_IN_SECONDS ) >= 5;