@@ -1226,14 +1226,37 @@ protected function render()
12261226 'category_name ' => isset ($ _GET ['category ' ]) ? sanitize_text_field ($ _GET ['category ' ]) : '' ,
12271227 'tag ' => isset ($ _GET ['tags ' ]) ? sanitize_text_field ($ _GET ['tags ' ]) : '' ,
12281228 ];
1229+ $ args ['s ' ]=null ;
12291230 if (isset ($ _GET ['category ' ]) && ($ _GET ['category ' ]) == "all " ) {
12301231 unset($ args ['category_name ' ]);
12311232 }
12321233 if (isset ($ _GET ['date ' ])) {
1233- $ date_query = [
1234- 'after ' => $ _GET ['date ' ],
1234+
1235+ // Check the format of the provided date
1236+ if (substr ($ _GET ['date ' ], -1 ) == 'm ' ) {
1237+ $ date_query = [
1238+ 'year ' => intval (substr ($ _GET ['date ' ], 0 , 4 )),
1239+ 'month ' => intval (substr ($ _GET ['date ' ], 5 , 2 )),
1240+ 'day ' => array (
1241+ 'start ' => 1 ,
1242+ 'end ' => cal_days_in_month (CAL_GREGORIAN , intval (substr ($ _GET ['date ' ], 5 , 2 )), intval (substr ($ _GET ['date ' ], 0 , 4 ))),
1243+ ), ];
1244+ }
1245+ if (strlen ($ _GET ['date ' ]) === 4 ) {
1246+ // Only year provided (YYYY)
1247+ $ date_query = [
1248+ 'year ' => intval ($ _GET ['date ' ]),
1249+ ];
1250+ }
1251+ else if (!substr ($ _GET ['date ' ], -1 ) == 'm ' ) {
1252+ // Full date provided (YYYY-MM-DD) - reuse previous logic
1253+ $ date_query = [
1254+ 'year ' => intval (substr ($ _GET ['date ' ], 0 , 4 )),
1255+ 'month ' => intval (substr ($ _GET ['date ' ], 5 , 2 )),
1256+ 'day ' => intval (substr ($ _GET ['date ' ], 8 , 2 )),
12351257 'inclusive ' => true ,
1236- ];
1258+ ];
1259+ }
12371260 $ args ['date_query ' ] = $ date_query ;
12381261 }
12391262 if ($ settings ['all_post ' ] == 'all ' ) {
@@ -1443,7 +1466,7 @@ protected function render()
14431466
14441467 foreach ($ date_parts as $ part ) {
14451468 if ($ i == 1 ) {
1446- $ date_array [1 ] = $ date_array [1 ] . '/01 ' ;
1469+ $ date_array [1 ] = $ date_array [1 ] . '/01 m ' ;
14471470 }
14481471 $ date_link = add_query_arg ('date ' , $ date_array [$ i ], $ page_link );
14491472 echo ' <a href=" ' . $ date_link . '" class="date"> ' . ucfirst ($ part ) . '</a> ' ;
0 commit comments