Interesting task indeed. Here’s what I would do:
- Create my own plugin with a widget. You can always use plugin boilerplate or widget boilerplate as starting points.
- My widget would look like the default calendar, except it would also have the ‘prev”https://wordpress.stackexchange.com/”next’ links, as you mentioned.
- I would then copy-paste and adjust the
get_calendar()
function located inwp-includes/general-template.php
, which is responsible for populating the calendar HTML. I’d call it something nice and unique, likemy_get_calendar()
. - Connect my widget with my function via AJAX calls triggered by clicks on ‘prev”https://wordpress.stackexchange.com/”next’ links, passing month and year as parameters. The
my_get_calendar()
function would catch those and return either JSON or HTML (depending on where you prefer the markup generation to occur – either in the front-end or back-end). - In my widget’s JS on
document.ready
I would call my back-end function to initially populate the calendar, and then attach click handlers to ‘prev”https://wordpress.stackexchange.com/”next’ links. - Share end result with the world by either posting it on GitHub or in WordPress plugins repository, or both.