Home Forums Backend Issues (wp-admin) year picker


year picker

  • Does anyone know if it’s possible to use a date picker with the year only(drop down with years) or should I use a select field type? Thanks!

  • I would use a select field.

  • 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');
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.