Post filtering by year & month

Here is some code that may work:

[[!pdoResources?
    &parents=`1`
    &tpl=`myTpl`
    &limit=`0`
    &sortby=`publishedon`
    &sortdir=`desc`
    &where=`[[!getDateFilter]]`
]]

Snippet getDateFilter: Reads the values of the GET-parameters and create the where property.

<?php
$year = date('Y'); //current year as default
$month = 0;
if (isset($_GET['year'])) {
    $year = intval($_GET['year']);
}
if (isset($_GET['month'])) {
    $month = intval($_GET['month']);
}

if ($month > 0){
    //DATE_FORMAT(FROM_UNIXTIME(publishedon), '%Y-%m') = '2022-04'
    return "DATE_FORMAT(FROM_UNIXTIME(publishedon), '%Y-%m') = '" . $year . "-" . sprintf('%02d', $month) . "'";
} else {
    //DATE_FORMAT(FROM_UNIXTIME(publishedon), '%Y') = '2022'
    return "DATE_FORMAT(FROM_UNIXTIME(publishedon), '%Y') = '" . $year . "'";
}

Then call the page with the GET-parameters:

.../myposts.html?year=2022
.../myposts.html?year=2022&month=4