Google Docs Shortcode
Google Docs Shortcode is a small plugin for WordPress that allows you to use a shortcode to easily embed a Google Doc into your blog posts or pages.
Recommended: Install the Shortcake plugin to get instant Google Doc previews in the WordPress editor.
This plugin was developed for the CUNY Academic Commons. Licensed under the GPLv2 or later.
How to Use
Embedding a document, slide or sheet
- First, you'll need to find the public URL of your Google Doc file. Follow the guide below, then move on to step 2.
- Now navigate to your WordPress dashboard and open up the post or page where you want to embed your document. On a new line, type the following shortcode and paste in the link you copied, above:
[gdoc link="THE LINK YOU COPIED" height="800"]
You can customize the shortcode by using some custom parameters mentioned below.
Embedding an audio file
Follow the steps above, but change the shortcode to:
[gdoc link="THE LINK YOU COPIED" type="audio"]
type is set to
When you embed an audio file, we will use the browser's native HTML5 audio player.
Embedding any other file
For every other file type (image, PDF, Microsoft Office, etc.), follow the steps above, but change the shortcode to:
[gdoc link="THE LINK YOU COPIED" type="other"]
type is set to
When you embed a miscellaneous file, we will use Google's preview embed viewer to display the file.
Embedding a form
- Login to Google Drive and locate your form. Open it.
- Next, navigate to View > Live form. This should take you to the public version of the form. Copy the URL from your browser's address bar.
- Follow step 2 from the "Embedding a document, slide or sheet" section above.
Sharing a Google Drive file and getting the link
- Let's start by logging in to your Google Drive. Next, find the item you want to embed.
- Now, right-click on the file and click on Share:
- You should now be on the Share with Others window. If the "Get Shareable link" is not green, click on it:
This will make your Google Drive file shareable to anyone with the link, which will allow us to embed the file in your post.
- Now, copy the link from the text field highlighted below:
Other shortcode parameters
Here are some other custom parameters you can use with the shortcode:
"width" - By default, this tries to use your theme's content width. If this doesn't exist, the width is "100%". Fill in this value to enter a custom width.
"height" - Enter in a custom height for your Google Doc if desired. Defaults to "300". Avoid percentages.
"seamless" - This parameter is only applicable to Documents. If you enter "0", this will show the Google Docs header and footer. Default value is "1", which means that no Google Docs header or footer will be shown. Note: This option only works if your document was published to the web and not link-shared.
"size" - This parameter is only applicable to Slides. You can enter in "small", "medium" or "large" to use the presentation preset sizes. Dimensions for these presets are: small (480x299), medium (960x559), large (1440x839). To set a custom width and height, use the "width" and "height" parameters listed above instead.
"type" - This parameter is only applicable to non-Google Doc types. If the file you want to embed is an audio file, set the type to
audio. Otherwise, set the type to
otherfor every other file type (image, PDF, Microsoft Office, etc.) and we will attempt to embed the file using Google's preview embed viewer.