How can I fix the date with multiple Wordpress CPT date? An example, the custom post "John The Man" on "Canada" CPT the birthday is "Thursday 05 May 1960". How can I compare with only date and month (05 May) with every year (2024, 2025, etc), and skipping birthyear+time? Now it is all records/row without date, or no records/row with date. I have tried 'where' and 'meta_query' on the dates.
//index.php:
echo birthday("Canada", "dmy", "birthday", "Canada ...");
echo birthday("USA", "dmy", "birthday", "USA ...");
echo birthday("Mexico", "dmy", "birthday", "Mexico ...");
echo birthday("El Salvador", "dmy", "birthday", "El Salvador...");
//and so on ...
function birthday($custompost, $dmy, $birthday, $message) {
$current_date = new DateTime();
$datemonth = $current_date->format("d M");
$args = array(
'post_type' => $custompost,
'post_status' => 'publish, private',
'limit' => '-1',
//this does not working with 'where'
//'where' => "DATE_FORMAT(CAST(birthday.meta_value AS date), '%d %c') = '$datemonth'", //not working
//this does also not working with 'meta_query'
'meta_query' => array(
array(
'key' => 'birthday',
'value' => $datemonth, //not working
//'value' => '05 May', //not working
//'value' => '%5%May%', //not working
//must remove the year+time, or else it can be only 1 birthday (e.g. Thursday 05 May 1960) for each country
//'value' => date('Y/m/d'),
//'value' => date('Y/m/d',time()),
'type' => 'DATE', //or 'NUMERIC', not working
//'compare' => 'LIKE', //or EXISTS, IN, could compare with from "Thursday 05 May 1960" to "05 May", skipping day and year. Not working
)
) //end meta_query
); //end args
$posts = get_posts( $args );
echo "<pre>posts:";print_r( $posts );echo "</pre>";
echo "<pre>query:";print_r( $query );echo "</pre>";
}; //end function
```