Connect javascript calendar to CPT ACF fields?
Question
I’m wondering how to link data from CPT ACF fields to a JS calendar on a page.
I’m currently learning JS so sorry if this is a basic question!
I’m building an ‘events calendar’ calendar view using a codepen snippet. This is where I’m up to.
I’ve created the events as a CPT ‘events’ and ACF custom fields and would like to populate the calendar with the relevant fields.
The snippet starts with the below code. How can I replace ‘Event 1, Location’ with dynamic data from my ‘events’?
// generate events
var eventDates = {}
let day1 = formatDate(new Date(new Date().setMonth(new Date().getMonth() + 1)))
eventDates[day1] = [
'Event 1, Location',
'Event 2, Location 2'
]
let day2 = formatDate(new Date(new Date().setDate(new Date().getDate() + 40)))
eventDates[day2] = [
'Event 2, Location 3',
]
Thanks!
0
3 weeks
2023-01-06T10:18:27-05:00
2023-01-06T10:18:27-05:00 0 Answers
0 views
0
Leave an answer