Create a Weekly view custom Calendar in WordPress


For a recent project, I needed to develop a calendar with a weekly view that would display events based on 3 different custom post types.
Since the website required a very custom setup, I didn’t want to use an event plugin, since it would have limited the amount of customization that the client needed.

So once the design was ready, the tricky part kicked in: developing a light & dynamic calendar, in a weekly view, with current day & events highlighted, that would show different types of events happening each day.

wordpress weekly calendar php javascript

Thankfully PHP (specifically PHP 5.3+ for Relative Formats) gave me all the necessary tools:

time()
mktime()
strtotime()
Relative Formats
NumberFormatter Class

The resulting HTML & PHP, already integrated with some custom WordPress queries (that you will need to adjust to your own needs), is in this Gist.

You will notice the use of WordPress transients, this is to cache the queries as much as possible to improve performance and page load.

The calendar can scroll by month and by week obviously, on click of a certain day it also highlights it and adds a dot inside the circles, which represent all the different types of event, showing at the bottom their title.

Now, the original version was a gold design, so here is the CSS for it.

And finally, the Javascript which handles the scrolling and active year/month/day/events transitions.

Now that you have your sweet weekly calendar, you might also be interested in creating a handy .ics calendar file, for all your events.

I’m a Digital Consultant, Web Designer & Developer, specialized in WordPress.
I’ve been making websites for 17 years and have specialized in WordPress since 2009.
I like to work with PHP/MySQL, HTML5/CSS3/Javascript, Twitter Bootstrap and, of course, WordPress.
I help companies, professionals and startups grow with technology, I hand-pick the perfect team for them, plan projects from the ground-up, develop & deploy websites, online stores and apps.