From c516cf815258f61cf6a6c7ff4d16076243085480 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Fri, 18 Aug 2023 14:46:48 +1000 Subject: [PATCH] Add suggested post_date > 0 fix to resolve #171 (#174) --- msm-sitemap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msm-sitemap.php b/msm-sitemap.php index 4f199924..ceeab3d0 100644 --- a/msm-sitemap.php +++ b/msm-sitemap.php @@ -330,7 +330,7 @@ public static function disable_canonical_redirects_for_sitemap_xml( $redirect_ur public static function get_post_year_range() { global $wpdb; - $oldest_post_date_year = $wpdb->get_var( "SELECT DISTINCT YEAR(post_date) as year FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY year ASC LIMIT 1" ); + $oldest_post_date_year = $wpdb->get_var( "SELECT DISTINCT YEAR(post_date) as year FROM $wpdb->posts WHERE post_status = 'publish' AND post_date > 0 ORDER BY year ASC LIMIT 1" ); if ( null !== $oldest_post_date_year ) { $current_year = date( 'Y' );