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:

Relative Formats
NumberFormatter Class

Media Temple Hosting

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.

Media Temple Hosting

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.

Jany Martelli

I’m a Digital Consultant, Front-End Developer, specialized in WordPress.
I help companies, professionals and startups grow with technology and a winning digital strategy, I hand-pick and coordinate the perfect team for them, plan projects from the ground-up, develop & deploy websites, online stores and apps.