I am using Advanced Custom Fields in my WordPress project. In it I have added 2 datepickers as custom fields for pages.
Now the main problem is whenever I add a new page both datepickers by default show up empty, but I want to set the current date of the server as a default, that is whenever I add a new page both the date pickers should have the current date of the server by default in it.
In advance thanks for the help.
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.
And in wordpress’ php you can do :
Adding a default value to an ACF date picker can be achieved by using a filter:
Replace
startdate
with any field name you want to apply this filter to.This filter goes into your theme’s (or child-theme’s)
functions.php
or into a template file if it makes sense for you.Source: https://support.advancedcustomfields.com/forums/topic/date-picker-prefilled-to-today/