Any ideas how to set the month view on Event Calendar to set to a specific month i.e June?
Hi there, @user2343
Do I get it right that you’d like to skip months without events and show the month, where you have the closest event by default?
If this is the case, this code will help you achieve this:
let eventsInCalendar = 0;
const myInterval = setInterval(() => {
const calendar = document.getElementsByClassName('fc-daygrid-day');
let eventInTheCurrentMonth = false;
for(let i = 0; i < calendar.length; i++) {
let month = calendar[13].getAttribute('data-date').split('-')[1];
let currentEventMonth = calendar[i].getAttribute('data-date').split('-')[1];
eventInTheCurrentMonth = month == currentEventMonth;
if(calendar[i].innerHTML.includes('fc-event-start') == 1 && eventInTheCurrentMonth) {
eventsInCalendar++;
}
}
if (eventsInCalendar == 0) {
const buttonNext = document.querySelector('[class*="next-button"]');
buttonNext.click();
} else {
clearInterval(myInterval);
}
}, 300);
Please add it to the Custom JS field on the Settings tab of your widget’s settings and let me know if it helped
Hey @Max!
Echoing the OP’s question – Is it possible to have the calendar load to a specified month (ex. June 2026) rather than the current month?
Thanks!
Hey there and welcome aboard, @user618303
Yep, the code from the message above should work great. Please add it to the Custom JS field on the Settings tab of your widget’s settings and let me know if it helped
Note: Custom JS operates only upon widget installation, not in preview mode.
Hi @Max – thanks for the quick reply!
Unfortunately, when published on the live site, the code advances the calendar but does not stop advancing, despite there being months with events.
Could you please send me a link to the page, where your widget is installed? I’ll be happy to check it for you