In WordPress possiamo contrassegnare come obsoleti i post più datati.
La soluzione è la seguente:
function my_mark_as_old( $classes ) {
if( is_single() ) {
global $post;
$year = (int) get_the_date( 'Y', $post->ID );
$current_year = (int) date( 'Y' );
if( ( $current_year - $year ) > 2 ) {
// Più di 2 anni
$classes[] = 'old';
}
}
return $classes;
}
add_filter( 'body_class', 'my_mark_as_old' );