public static get_post_year_range ( ) : int[] | ||
return | int[] | valid years |
public static function get_post_year_range()
{
global $wpdb;
$oldest_post_date_gmt = $wpdb->get_var("SELECT post_date FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_date ASC LIMIT 1");
$oldest_post_year = date('Y', strtotime($oldest_post_date_gmt));
$current_year = date('Y');
return range($oldest_post_year, $current_year);
}