カスタムフィールドに8桁入力とした場合(1980年5月16日→19800516)
$birth = get_post_meta($post->ID,'birth',TRUE); $birthY = substr($birth,0,4); $birthMD = substr($birth,4,4); $todayY = date('Y'); $todayMD = date('md'); $age = $todayY - $birthY; $age = ($todayMD < $birthMD)?$age-1:$age;//誕生日前なら1年を引く