I try to use ACF in combination with JS. I have a timer on our website and I want it to be editable in the WordPress Dashboard and not only in the code.
If this was just PHP I knew how to do it, but I am kinda new to JS so I need some guidance.
This is what I want to accomplish (example: based on how it can be done in PHP).
// Here should come the fields like get_sub_field but then for JS..
// var Date-Y = get_sub_field(‘date-year’);
// var Date-m = get_sub_field(‘date-month’);
// var Date-d = get_sub_field(‘date-day’);
// var Date-h = get_sub_field(‘date-hour’);
// So I can link for example ‘date-year’ in the dashboard in custom fields to be in the
// page where the timer is and edit the year in the dashboard.
// But I think this is not the right way of coding it
// Then link the variables to the places where I want them to be. It’s about the variable
var eventDate = new Date(2019, 10, 7, 15);
// So instead of
// 2019: Date-Y
// 10: Date-m
// 7: Date-d
// 15: Date-h
// And then I can add these in WordPress dashboard as Advanced custom fields — linking
// them to the right variable, so that I can edit the date within WordPress itself and
// not in the code
I hope my issue is clear and someone is able to explain how I do this in JS.