Home Forums Backend Issues (wp-admin) year picker Reply To: year picker

  • I know this is a pretty old post, but if anyone else wanted the code to make this happen:

    function sevenYearSelect($field) {
        $currentYear = date('Y');
        // Create choices array
        $field['choices'] = array();
        // Add blank first selection; remove if unnecessary
        $field['choices'][''] = ' ';
        // Loop through a range of years and add to field 'choices'. Change range as needed.
        foreach(range($currentYear-1, $currentYear+5) as $year) {
            $field['choices'][$number] = $year;
        // Return the field
        return $field;
    add_filter('acf/load_field/key=field_0000000000000', 'sevenYearSelect');