I've noticed that in the date picker the CSS is not applied correctly - see image.
I think it's something to do with this:
.ui-datepicker tr:first-child {
border: 1px solid
#27292b;
}
Could that just not be applied to the thead?
Also, could a custom date field display a default date in the backend, to save repeatedly picking today? It has today pre-selected when you click to pick a date, but it'd be good if it displayed it without having to click.
Hello,
Q1) Could that just not be applied to the thead?
You can setup your CSS codes like this:
.ui-datepicker thead {
/**here add CSS codes... **/
}
Q2) could a custom date field display a default date in the backend, to save repeatedly picking today?
No, there isn't such kind of feature, it is required to click and pick a date, you might consider custom codes, for example:
https://stackoverflow.com/questions/46448877/jquery-datepicker-set-initial-date
Q1) Yes I thought there was a problem with your CSS but it may be a theme/plugin over-riding.
Q2) I couldn't get the jquery to work. I have used the code below and added to my functions.php which does seem to work. Is this OK? It only works for the first time of data entry but when my client is doing a bulk lot of data entry but it can be useful.
/* Set Today's Date Initial Entry */
function set_date_field( $post_id ) {
$date = get_post_meta($post_id, 'wpcf-your-date');
if(empty($date)){
update_post_meta($post_id, 'wpcf-your-date','today');
}
}
add_action( 'save_post', 'set_date_field' );
Discovered the above wouldn't save as we need to use unix timestamp, whereas the below saved fine. Can you confirm the code is OK?
/* Set Today's Date for Policy Date */
function set_date_field( $post_id ) {
$date = get_post_meta($post_id, 'wpcf-policy-date');
$now = time(); // Current time and date as a timestamp
if(empty($date)){
update_post_meta($post_id, 'wpcf-policy-date', $now);
}
}
add_action( 'save_post', 'set_date_field' );
I think your new PHP codes are OK.