I'm trying to integrate FullCalendar with jQuery into my WordPress site using the Divi theme.
I have successfully:
Loaded FullCalendar via functions.php Ensured jQuery and Moment.js are enqueued correctly Logged the event data in the console after adding an event Issue: Despite everything looking correct in the console, the event does not appear on the calendar after being added. Additionally, I receive the following errors:
Deprecation Warning about date formatting: "Value provided is not in a recognized RFC2822 or ISO format". FullCalendar does not render the event even though it logs successfully in the console. No server storage (events are stored in a local array for now).
Here is my FullCalendar initialization script inside functions.php:
function initialize_fullcalendar() {
?>
<script>
jQuery(document).ready(function($) {
if ($("#calendar").data("fullCalendar")) {
console.log("FullCalendar already initialized. Skipping re-initialization.");
return;
}
console.log("FullCalendar is initializing...");
var eventList = []; // Store events locally
$("#calendar").fullCalendar({
header: {
left: "prev,next today",
center: "title",
right: "month,agendaWeek,agendaDay"
},
selectable: true,
editable: true,
eventLimit: true,
events: function(start, end, timezone, callback) {
console.log("Loading events...", eventList);
callback(eventList);
},
select: function(start, end) {
var eventTitle = prompt("Enter Event Title:");
if (eventTitle) {
var eventData = {
id: eventList.length + 1,
title: eventTitle,
start: moment(start).toISOString(),
end: end ? moment(end).toISOString() : null
};
console.log("Adding Event:", eventData);
eventList.push(eventData);
$("#calendar").fullCalendar("renderEvent", eventData, true);
}
$("#calendar").fullCalendar("unselect");
}
});
});
</script>
<?php
}
add_action('wp_footer', 'initialize_fullcalendar', 20);
Why are the events I add not displaying? Any help would be greatly appreciated