This is a question that’s come up several times as people are migrating departmental sites into WordPress. It seems WordPress doesn’t like iframes, and they don’t consider that a bug. While I agree there are still a few security concerns with iframes, they aren’t nearly as much of a scream-and-run-away as they were in older browsers. WordPress still considers them too much of a risk, and won’t let anybody except a global administrator put an iframe into a post or a page. If anybody else does, that code just gets stripped out when they save the page. And if an admin does put in an iframe, as soon as anybody else edits the page, the code gets stripped. That’s why some people were seeing calendars disappear.
Luckily, someone wrote a WP plugin that lets any editor put in iframes as shortcodes. That plugin is activated on all our sites. So here’s what you do to get a google calendar embedded into a WP page:
- Get the iframe HTML code:
In Google Calendar, look in the My Calendars sidebar for the calendar you want to embed in WordPress. In the dropdown menu for that calendar, click settings to go to the settings page. On that page will be a snippet of HTML code you can use to embed the calendar. That snippet will look something like:
<iframe src="https://www.google.com/calendar/embed?src=swartzer%40mail.wou.edu&ctz=America/Los_Angeles" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
- Put that code into WordPress:
Edit the page where the calendar needs to display. Paste in the HTML snippet, delete the </iframe> from the end, and change the angle brackets to square brackets. The snippet should now look something like:
[iframe src="https://www.google.com/calendar/embed?src=swartzer%40mail.wou.edu&ctz=America/Los_Angeles" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"]
- That’s it!
Just hit Update on the page to save it, then view it. If you don’t see the calendar, let me know.
Oh, and this trick works on any iframe, not just Google calendars.