Support

Account

Home Forums Search Search Results for 'date picker'

Search Results for 'date picker'

topic

  • Solved

    Date picker only goes 100 years back

    Hello,

    I have a date field “Birth date” and I noticed that the date picker only goes back to 1923. Therefore, it’s not possible to pick the birth date for people born before 1923. I know that the date can be entered manually, but for some users this is a problem. Is there a way to omit this restriction?

    Regards

  • Solved

    Repeater field meta_query between 2 dates

    I can’t get this to work at all, I’m trying to build into a rest_{post_type}_query but struggling to get it to work on a regular query not sure what I’m doing wrong all so I’m trying to get any results from this query between 2 dates:

    $args = array(
        'post_type' => 'tours',
        'posts_per_page' => -1,
        'meta_query' => array(
            array(
                'key' => 'linked_tours', // Name of the repeater field
                'value' => array( '20230822', '20230925' ), // Array of start and end dates
                'type' => 'DATE',
                'compare' => 'BETWEEN', // To check if the date falls within the range
                )
            ),
    );

    linked_tours is the name of a repeater field on the tours post type containing 2 sub_fields, a datepicker and a post object. I’m trying to return tours between 2 dates but getting no results.

    I’ve tried a few combinations on the ‘key’ that I found on the forum but none working. Sorry if this has been asked before but I haven’t found a solution and any help would be appreciated.

  • Helping

    Merge options repeater fields and custom post type

    I realise this is a big ask but I can’t work out how to do this.

    I have an options page that generates publications that are just a PDF link.

    It asks for a featured image, excerpt, PDF link, and date

    I also have a custom post type called ‘publications’

    I am trying to merge these two together and then output them sorted by date (the date picker for the repeaters and the published date for posts)

    My Repeater field is setup like so:

    <?php if ( have_rows( 'publications', 'option' ) ) : ?>
    	<?php while ( have_rows( 'publications', 'option' ) ) : the_row(); ?>
    		<?php the_sub_field( 'publication_name' ); ?>
    		<?php $publication_image = get_sub_field( 'publication_image' ); ?>
    		<?php if ( $publication_image ) : ?>
    			<img src="<?php echo esc_url( $publication_image['url'] ); ?>" alt="<?php echo esc_attr( $publication_image['alt'] ); ?>" />
    		<?php endif; ?>
    		<?php the_sub_field( 'publication_description' ); ?>
    		<?php $publication_file = get_sub_field( 'publication_file' ); ?>
    		<?php if ( $publication_file ) : ?>
    			<a href="<?php echo esc_url( $publication_file['url'] ); ?>"><?php echo esc_html( $publication_file['filename'] ); ?></a>
    		<?php endif; ?>
    		<?php the_sub_field( 'file_link_description' ); ?>
    		<?php the_sub_field( 'pdf_date' ); ?>
    	<?php endwhile; ?>
    <?php else : ?>
    	<?php // No rows found ?>
    <?php endif; ?>

    My custom post type is just called ‘publications’

    ACF have said I need to:

    Create a Custom Post Type: First, you’ll want to create a custom post type specifically for the publications (e.g., “Publications”).
    Set up ACF Repeater Field: Set up an ACF repeater field group for the additional content that doesn’t fit the typical blog post format. This repeater field can include fields for an image, text, link, and date field (if you want to order by date).
    Add Content as Custom Posts or Repeater Fields: For the actual blog posts, create them using the standard WordPress post editor, and assign the “Publications” custom post type to them. For the other content that consists of just an image and a link to a PDF, use the ACF repeater field to add that information to a specific page or a custom options page.
    Custom Query to Retrieve and Display Content: Now comes the part where you combine both types of content on your publications page. In your page template (or a custom template), you’ll use a custom query to fetch both the regular blog posts and the ACF repeater field data.

    a. Retrieve Blog Posts: Use a regular loop or WP_Query to get the blog posts assigned to the “Publications” custom post type, and display them in a list or grid format.
    b. Retrieve Repeater Field Data: To fetch the data from the ACF repeater field, you can use the get_field function with the appropriate field name and iterate through the rows to display the image, text, and link.
    c. Merge and Sort: Combine the data from both sources into a single array or object and sort them based on the publishing date (you can use the date field in the repeater field).

    Display the Combined Content: Finally, loop through the sorted and merged array/object to display all the content together on the publications page.
    Remember that the actual implementation may vary depending on your specific use case and the structure of your theme. Always make sure to properly sanitize and validate any user-generated content to ensure security.

    This approach should allow you to have a flexible publications page that can include both traditional blog posts and the ACF repeater field content, presented in a unified manner sorted by date.

    But I don’t know how to do this.

    Any help would be greatly appreciated
    Thanks

  • Solved

    Conditional display on specific fields based on post type

    I have a field group that I’m displaying on multiple post types but there are specific fields I’d like to display only on specific post types. Some are fields inside repeater fields others are “Normal” fields.

    For example something like this

    Radio buttons (Post types A and B)
    Text Field (Post types A and B)
    Date time picker (Post Type B only)
    Repeater field 1 (Post types A and B)
    —Image Field (Post types A and B)
    —Url Field (Post types A and B)
    —Date time picker (Post Type B Only )
    Repeater field 2 (Post types A and B)
    —Image Field (Post types A and B)
    —Url Field (Post types A and B)
    —Date time picker (Post Type B Only)

  • Solved

    Unable to set post status to future when setting future date via ACF field

    Hi all, I’ve been struggling with this for days now.

    So I’m setting the post date of a custom post type based on an acf field, the dates will alway be in the future so I want the post to be “scheduled”. While the date does get properly set to the future https://share.getcloudapp.com/yAu9ylvN it’s still set at published even though I’m attempting to set post status to “future” it doesn’t do so. If I manually change the date in the WP date time picker the “update” button changes to a “Schedule” button and it works properly but for some reason setting it from an acf field doesn’t allow one to also set the post status to future. Code below.

    
    add_action("acf/save_post", "test_update_post_date_from_acf");
    function test_update_post_date_from_acf($post_id)
    {
      $post_date = get_field("start_date");
      $post = wp_update_post([
        "ID" => $post_id,
        "post_date" => $post_date,
        "post_status" => "future",
      ]);
    }
    
  • Helping

    Date front end display format

    I’m struggling to convert an ACF date picker field to be displayed in the correct format on the front end.

    I’m using this snippet to display the 2 product custom fields on the order confirmation and the associated email.

    add_action( 'woocommerce_order_item_meta_start', 'order_item_meta_start', 10, 4 );
    function order_item_meta_start($item_id, $item, $order, $plain_text) {
    	$the_order_id = $order->get_id();
    	$order_items = $order->get_items();
    	$custom_field_variable1 = get_post_meta( $item->get_product_id(), 'competition_reference', true ); // Change custom_field_name to the name of your custom product meta field
    	$custom_field_variable2 = get_post_meta( $item->get_product_id(), 'competition_draw_date', true ); // Change custom_field_name to the name of your custom product meta field
    	echo '<p>Competition Reference: ' . $custom_field_variable1 . '<br>Competition Draw Date: ' . $custom_field_variable2 . '</p>';
    }

    It works in the fact it displayed the ACF data, but it displays the date as YYYYMMDD rather than my ACF return format of dd/mm/YYYY

    Product
    LEGO® Star Wars™ Darth Vader Helmet (75304)
    Competition Reference: LegoDV_001
    Competition Draw Date: 20230630

    How can I return the date correctly?

  • Solving

    Shortcode of datepicker within repeater field

    Is there a shortcode to output the date selected in the date picker subfield?

    The output format should be ‘d F Y’

    My repeater field is called course_dates
    My date picker subfield is called start_date

    Someone can help me out?

  • Solved

    Nested repeater and programmatically add values

    Hello all.

    I use ACF Pro and I’ve created a nested repeater field for working hours in a CPT.

    The structure is like that:

    Repeater Field [Field Name: working_hours] (Working Days) (To repeat the week days and working hours of the days)
    Select [Field Name: day] (contains the names of the week days)
    Repeater Field [Field Name: working_hours] (Working Hours repeater to add the working hours per day)
    Time Picker [Field Name: from] (From time)
    Time Picker [Field Name: to] (From time)

    Now, what I need to achieve is to populate the fields with data programmatically.

    What I have try so far is to use the update_field and a structure like this as value:


    $options = [
    "working_hours" => [
    [
    "day" => "Monday",
    "working_hours" => [
    [
    "from" => "09:00",
    "to" => "14:30",
    ],
    [
    "from" => "17:00",
    "to" => "20:30",
    ]
    ]
    ],
    // ... other days here
    ]
    ];

    But this creating only the top level of repeated elements and the child fields are all empty.

    For example, if I have a seven days values (first working_hours contains seven child arrays) in the post I get seven repeated items, all showing Monday and no registered hours.

    Can someone show me how can I achieve this programmatically?

    Thank you in advance !

  • Solving

    Date time picker not working

    WP version : 6.2.2
    ACF version : 6.1.6
    CPT version: 1.13.4
    I am having custom post type in my site in that i have added two ACF fields which are of type Date Time Picker. If i entered some value by choosing date and time and save, the values are cleared. It is not saving. Same for time picker field.

    https://tinyurl.com/2poyefzh

  • Solving

    return format date picker problem

    Hello fellow acf users,

    I have set the return format of the date picker to F, Y. I am using the search & filter plugin and it displays it in the filter form as (20230303).

    Even if I set the display and return format to F, Y, it still doesn’t work. Does anyone know how i can solve this?

    thanks in advance for your help!

  • Unread

    ACF Date Picker Data To Gravity Forms Date Field

    Hi all,

    I have a date field created using an ACF date picker which is set up as user meta for date of birth.

    Using the Gravity Forms User Registration add-on/update user, I’m trying to auto populate a gravity form date field with the corresponding dd/mm/yyyy data. Is there a way to do this using something like {user:date_of_birth:dd} {user:date_of_birth:mm} {user:date_of_birth:yyyy} or something like that?

    We need to allow users to view and edit their date of birth in case it was originally entered incorrectly.

    Thanks

  • Solved

    Ninja Forms and ACF Date/Time Picker Not Behaving

    I’ve got a Ninja Form with a Date/Time Picker. I am using update_field to save the value in the database, but it will not work correctly and instead saves the value as:

    a:4:{s:4:"date";s:10:"2023-03-07";s:4:"hour";s:2:"04";s:6:"minute";s:2:"30";s:4:"ampm";s:2:"pm";}

    This breaks the database record since this is not a properly formatted Date/Time – which should be converted to YYYY-MM-DD HH:II:SS in the database by update_field

    What’s weird to me, is that if it’s a Date picker only, the update_field function works just fine. So it appears the issue is with the Time part.

    It’s infuriating.

  • Unread

    ACF Date and Time Format Differs When Used in List Category Posts Shortcode

    The date (j F Y) and time (H:i) format set in ACF differs when we use it in the “List category posts” shortcode.

    In the ACF (custom fields) plugin it’s set to the above mentioned, which works fine when using [acf field="webinar_date"] in example. Whenever we try to implement it the List Categor Posts shortcode, the date displays as YYYYMMDD (20230316 instead of 16 March 2023) and the time as HH:MM:SS (16:00:00 instead of just 16:00).

    The List Category Posts shortcode used, is as follows:
    [catlist excerpt=yes excerpt_size=20 id=91 pagination=yes numberposts=10 posts_morelink=”Register” customfield_display=”yes” customfield_display=”webinar_date,webinar_sast_start_time,webinar_sast_end_time,webinar_est_start_time,webinar_est_end_time” customfield_display_name=”no” customfield_display_separately=”yes”]

    Is there any way to fix this? We have tried numerous suggestions found online. The last solution we tried, is by including the below mentioned code in the functions.php file (via the Code Snippet plugin):
    function acf_smart_dates($field) {
    if ($field[‘webinar_date’]) {
    $field[‘webinar_date’] = date(‘dmY’,strtotime($field[‘webinar_date’]));
    }
    return $field;
    }
    add_filter(‘acf/prepare_field/type=date_picker’,’acf_smart_dates’);

    Thank you in advance for any suggestions.

  • Helping

    Is there a way to set a default value for a timepicker field?

    The title pretty much says it all.

    I have a timepicker field (start_time) that’s optional and only appears if someone has set a value on a datepicker field (start_date).

    I need to sort posts by start_date, and – if there is a value for the start_time field – sort by start_time within the posts for the start_date.

    I don’t see a way to set a default value for start_time when setting up the ACF.

    If there’s not a way to do it within the admin interface, is there a way to do it when retrieving the post meta data?

  • Helping

    Age calculation ouput

    I have a date of birth field and I need to learn how to create a way to calculate the persons age and display it in a post.

    I would imagine have the date of birth date picker field is obvious, but to I need to create another field like “age” where the calculated age can be output?

    Thank you for any suggestions

  • Helping

    Sort posts in a widget using 2 ACFs

    I have a field group for standard WP posts that includes among others) the following optional ACFs:

    • start_date – set using the Date Picker
    • start_time – set using the Time Picker; only available if start_date has a value

    To be clear: not all the posts that have start_date value also have a start_time value.

    I have custom widget that only displays posts that have a start_date value that’s (1) today or later, and (2) that’s within the next N days, where N is set in the widget admin interface. The posts are sorted by start_date in ascending order.

    That part all works just fine. Where I’m having trouble is being able to include the optional start_time ACF in the sort order so that posts would be listed like this:

    February 23
    February 24 10:00am
    February 26
    March 5 8:00am
    March 5 10:00am
    March 6

    This is the $args array that sorts (correctly) only by start_date:

        $args = array(
          'ignore_sticky_posts'=> 0,
          'post_type' => 'post',
          'post_status' => 'publish',
            'meta_query' => array(
              array(
                'key' => 'start_date', // ACF field for event start date
                'value' => date('Ymd', strtotime("+{$nr_days_ahead} days")), // restrict start date to no more than today + $nr_days_ahead
                'compare' => '<=',
                'type' => 'DATE'
              ),
              array(
                'key' => 'start_date', // ACF field for event start date
                'value' => $today,
                'compare' => '>=',
                'type' => 'DATE'
                )
              ),
          'posts_per_page' => $nr_posts,
          'cat' => $categories,
          'meta_key' => 'start_date',
          'orderby' => 'meta_value_num',
          'order' => 'ASC'
        );
    

    I spent quite a bit of time today with ChatGPT (just in case anyone feels like suggesting that approach), but never got anywhere (other than a couple critical errors that brought the site down, but I can manage that all by myself).

    Any suggestions?

  • Unread

    Custom query order by …

    Hello,

    i need your help plz 🙂

    I have this ACF fields :

    – type (checkbox type)
    – date with datepicker

    I have to order all my post with type = “mytype” (can we use ID ?) and order by date DESC

    How can i do this plz ?

    Thanks a lot.

    i did it :

    $prez = get_posts(array(
    ‘post_type’ => ‘myposttype’,
    ‘numberposts’ => -1,
    ‘meta_key’ => ‘date’,
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘DESC’
    ));

    but it’s not working.

  • Unread

    Datepicker fields

    hi!

    How to add multiple datepicker fields. First one is the main datepicker and other fields shows value based on that. For example on first one you select the date 12/2/2023. Second field show instantly week number automatically and the third one shows date + 7 days from the original date.

    I have a lunch list where is lunch menu for each day of the week showing lunch and the date. It would be helpful that you only have to pick a one date and others are calculated automatically.

  • Solved

    Datepicker to text field

    I want to have a text field but with a date picker. Or a date field with the possibility to write free text if I don’t want a date right now. It’s for a job board and sometimes we have a starting date for the position but sometime we just want to write “As soon as possible” or “Later this year”.

    Any idéas? 🙂

  • Helping

    Date Picker years before 1000

    Hi,
    we have an issue with the date picker field. If you want to enter dates before the year 1000 this is not possible. Neither 01/01/0818 nor 01/01/818 are working. Instead it jumps to 1918.

    The solution in this thread does not work for this issue, as mentioned in a comment there:
    https://support.advancedcustomfields.com/forums/topic/date-picker-field-starting-from-before-1913/

    What can we do? We have a website with historical data and need to be able to enter dates up until the year 200.

    Thanks for any input.
    Cheers Sascha

  • Helping

    WordPress Loop and Date Picker Problem

    Hello to all,

    I have created a custom post type in which I enter holidays and days that repeat every year.

    To enter the date I have taken the ACF Datepicker.

    This saves the date format in the database but always in the format: “YYYYMMDD”.

    The entered days are displayed in two loops in the template. One which shows the future days from today. And once the days, which are past and come only in the next year again.

    $args_future = array(
                'post_type' => 'repeat-days',
                'meta_key' => 'repeat_day_date',
                'posts_per_page' => -1,
                'orderby' => 'meta_value',
                'order' => 'ASC',
                'meta_query' => array(
                    array(
                        'key' => 'repeat_day_date', // ACF Feld Name
                        'compare' => '>=',
                        'value' => date("Y-m-d"),
                        'type' => 'DATE'
                    )
                ),
            );

    For the output, however, the year is uninteresting for me.

    Can I somehow tell the wordpress loop that it should only take into account the months and days?

  • Solved

    Save ACF custom field to date-time post

    Is it possible to set the “publish date” of my custom posts with a ACF datepicker field?

    My acf date picker field (startdate) is within a acf repeater field (courseinfo).

    Tried the following code, but didn’t work out (after publishing, the post date was set to january 1970).

    // Save ACF custom field to date-time post
    function my_acf_save_post( $post_id ) {
        $acfDate = get_post_meta($post_id, 'courseinfo_0_startdate', true);
        $my_post = array();
        $my_post['ID'] = $post_id;
        $my_post['post_date'] = $acfDate;
        wp_update_post( $my_post );
    }
    add_action('acf/save_post', 'my_acf_save_post', 20);

    Someone can help me out?

  • Unread

    Setting DateTimePicker Values in JS/Jquery????

    I want to set the value of a DateTimePicker field in the admin page by JS/Jquery but actually with no results.

    I googled a lot and tried a lot of suggestions with now more result.

    I get the data from a AJAX/JSON script and want to prefill the field.

    Any suggestions for me?

  • Solving

    datepicker return today's day if field empty

    hi. i’ve seen this reported if strtotime is used, which i do. i have a ‘single_event_date_end’ datepicker field which returns today’s (current) date if i leave the field empty, and i’d prefer it to return nothing, but i’m struggling to write a function that achieves this.

    the code i’ve tried is (variations on):

    function event_date_end()
    {
        $event_date_end = get_field("single_event_date_end"); 
    
        if ($event_date_end == null) {
            return false; 
        } else {
            return $event_date_end;     }
    }

    any advice appreciated. hiding it isn’t the problem; i’d just like null to = null.
    thanks in advance!

  • Solving

    Change the order in relationship picker

    Why doesn’t this work to change the order in a relationship picker (seen while editing post)

    add_filter('acf/fields/relationship/query/key={field_62585c13349c2}', 'my_acf_fields_relationship_query', 10, 3);
    function my_acf_fields_relationship_query( $args, $field, $post_id ) {
    
        // change the order in the relaionship picker
        $args['orderby'] = 'date';
    
        return $args;
    }
Viewing 25 results - 26 through 50 (of 790 total)