You can compare the post date to the date of your choice and enqueue different styles depending on the result:
<?php
function my_enqueue_styles_depending_on_date() {
global $post;
$style_switch_date="20201230"; // the trigger date
if ( is_single( $post->ID ) ) {
$post_date = get_the_date( 'Ymd', $post->ID );
if ( $post_date > $style_switch_date ) {
wp_enqueue_style( 'css_for_newer_posts' );
} else {
wp_enqueue_style( 'css_for_older_posts' );
}
}
}
add_action('wp_enqueue_scripts', 'my_enqueue_styles_depending_on_date');
Make sure to wp_register_script()
before you enqueue the style by it’s name (handle) or use the full wp_enqueue_style()
syntax.