Create .ics calendar files from WordPress posts & custom post types


For websites that feature events, either through plugin or custom post type, it might be important to allow user to download individual.ics calendar files.
ICS files can be opened in pretty much any calendar management app or software, like Outlook, Google Calendar and iCalendar.
Often, plugins provide the .ics generation functionality built-in, other times they require that you purchase an add-on… now you can do it yourself!

Copy and paste this script in your theme’s functions.php file and edit the parts that you need to customize:

Make sure that you read carefully through the code, especially the part with the date vars, location, organizer etc. so that your events are fully represented in the users’ calendar.

I personally like to use Types, to manage custom post types, custom taxonomies and custom fields, so a practical example in that case would be:

Media Temple Hosting

So, once looping through your posts, all you have to add is a link or button to the custom endpoint, carrying the post ID in the url parameter, like this:

The user will then be able to download and open the .ics file in whatever calendar app / software they want.

Now, why not pairing this cool feature with a handy weekly calendar for WordPress?

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.

By browsing this website, you explicitly and fully agree to the site's Cookies & Privacy Policy More Info

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close