"I did that in a simple test.
I created an Actor custom post type and added a date custom field "birthdate".
This gets stored as a UNIX timestamp (i.e. a number) in the wp_postmeta table. So when I create a view "Actors born today" I add a query filter for the birthdate custom field with the condition that it is a number equal to TODAY (see screenshot)."
I have an actor,screenwriter etc custom types, they have a string called "birth", that string is filled by editors, sometimes it is: "October 5, 1975", sometimes it is:"Oct 5th" or sometimes it is: "1956".
I couldn't resolve this with toolset TODAY as it returns for example today: 11/23/16, which doesn't match with 11/23/85 or any incorrect date in "birth" custom string creates an error so I had to manipulate birth string with php. I tried using a shortcode which was given here on forums. But that takes my load time up to 100secs; even worse.
This code particle was advised to someone else; I tried to use it but takes longer as I said:
function born_today_func( $atts ) {
extract(shortcode_atts(array(
'birthday' => get_post_meta(get_the_ID(), 'wpcf-birth', true),
), $atts)
);
if(((date('d', $birthday)) == date('d')) && (date('m', $birthday)) == date('m')){
return 1;
}else{
return 0;
}
}
add_shortcode( 'borntoday', 'born_today_func' );
So I switched back to what I put together before:
function getbirthbymonth($month,$bdata) {if ($month == 0) {$now = time();$month = date('n',$now);}
if(strlen($bdata)==4){$bday = DateTime::createFromFormat('Y', $bdata);}else{$bday = date('n', strtotime($bdata));}
if ( $bday == $month) {return 1;}else{return 0;}}
This works faster than shortcode yet still too long to use.
I need to loop through everyone to display any member that have birthday.
Open to any solutions that displays birthdays of the day on home page properly.