CMB2 toolkit: Compare 2 Dates and validate the Time
CMB2 toolkit: Compare 2 Dates and validate the Time
CMB2 toolkit: Compare 2 Dates and validate the Time
Try wrapping the trigger in a standalone callback. jQuery(function() { jQuery( “#datetimepicker” ).datetimepicker({ onClose:function(ct,$i){ my_callback(); } }); function my_callback() { jQuery( ‘body’ ).trigger( ‘update_checkout’ ); } });
Add this snippet and check according to your needed. add_action(‘acf/validate_save_post’, ‘my_acf_validate_save_post’); function my_acf_validate_save_post() { $start = $_POST[‘acf’][‘field_5fb0e816ea4fc’]; //$start = new DateTime($start); $start = strtotime($start); $end = $_POST[‘acf’][‘field_5fb0e83aea4fd’]; //$end = new DateTime($end); $end = strtotime($end); if( current_user_can(‘manage_options’) ) { acf_reset_validation_errors(); } // check custom $_POST data if ($start > $end ) { acf_add_validation_error($_POST[‘acf’][‘field-600e609de8ab8’], ‘End Date should … Read more
I think this is not possible with the API functions provided by ACF. I would try to save the values to a temporary array first and then sort the values inside the array with php (using krsort() for example). Something like this (just to give an idea): while(has_sub_field(‘in_the_news’)) { $date = get_sub_field(‘published_date’); // $date = … Read more
There’s no need for the custom meta SQL filter – the beauty of storing dates in the format Ymd is that you can treat them numerically, and MySQL will still be able to find events in a given “range” and sort them ascending/descending. I’ve done this recently on another site using ACF for start/end date: … Read more
You are using this flatpickr, right? So I don’t use Elementor and therefore, I haven’t tested this with Elementor or an Elementor form. However, from what I could see, all you need to do to make both the minDate and dateFormat work, is add this: if ( self.settings.dateFormat ) { pickerSettings.dateFormat = self.settings.dateFormat; } above … Read more
It depends on the datepicker plugin you are using. Mostly all datepickers will have a default value you can play with. Usualy it is set within the input text type that hosts the datepicker. <input type=”text” class=”datepicker” default-value=”2013/07/25″> And in wordpress’ php you can do : <input type=”text” class=”datepicker” default-value=”<?php echo date(“Y/m/d”); ?>”>
maybe you include your scripts ui-core and picker too early. Use wp_enqueue script() to include on the right hook. You must not include ui-core, only datepicker! example: wp_enqueue_script( ‘jquery-ui-datetimepicker’, \ $this->get_plugins_url( ‘js/ui.datetimepicker.js’, __FILE__ ), \ array(‘jquery-ui-core’) , 0.1, TRUE );` any tutorials: http://wpengineer.com/415/use-javascript-libraries-in-and-of-wordpress/ http://codex.wordpress.org/Function_Reference/wp_enqueue_script http://wpengineer.com/2028/small-tips-using-wordpress-and-jquery/ I use the datepicker on different plugins and works fine, … Read more
In many cases, in backend you may use: jQuery(‘#something’) instead of $(‘#something’)
When you query the posts with orderby argument as a event_date (it could be any field with date format) the posts are ordered by date, desc or asc. So the only thing you have to do afterwards is to group them by year and month. So: <?php $posts = get_posts(array( ‘post_type’ => ‘post’, ‘meta_key’ => … Read more