Documentation / How To Guides

How to import from Google Sheet to WordPress

Overview

ImportWP WordPress CSV importer allows you to import Google Sheets files into any WordPress posts, pages, or custom post types your theme or plugins have, in this article we will go through different ways you can import CSV files from google sheets into WordPress. By either downloading the CSV file and manually importing it, or by automating the WordPress CSV importer to download a fresh copy of the google sheets CSV file every time the import is run,  this is handy when you want to periodically check for changes on google sheets files and update your website accordingly.

WordPress Google Sheets Importer

Similar to using any data sheet application, google sheets allows you to download your data in multiple formats, to do this you need to open up your google sheets document, and select the data sheet that you want to export, by switching between sheets by using the tabs at the bottom left of the screen.

  1. Within the google sheets edit screen, choose from the file menu choose “Download as” > “Comma Separated Values”, this should prompt a file download in your browser.
  2. When creating an importer, under the section labelled “Where is the data being imported from?” choose “Uploaded file” and select the previously downloaded CSV file.
  3. Now you should have a google sheets CSV file imported into WordPress and you can continue to map the CSV file to your chosen import type.

Automate your WordPress Google Sheets Importer

You can skip the manual process of manually download your google sheets document each time you want to run the WordPress google sheets importer, but instead it can be automated to download the latest version of your google sheets document before importing into wordpress.

When creating the import using ImportWP WordPress importer plugin we can import csv files from a remote url and automating the import to import from google sheets periodically using our WordPress CSV cron importer, this section will take you through creating the google sheets url to import from, if you want to find out more about our cron importer read this article.

Create your Google Sheets WordPress Importer url

  1. Open up the google sheet document online that you want to import.
  2. We need to setup the document sharing to allow users with access to the list, so if you have a private document you need to click on the blue share button that is at the top right of the screen, once the sharing modal appears, click on the advanced link in the bottom right hand side, and change who has access setting this to either “anyone with a link” or to “public on the web”, make sure you read about what each option does and choose accordingly.
  3. In the google sheets url copy the section of text {DOCUMENT_ID} as shown on the following url https://docs.google.com/spreadsheets/d/{DOCUMENT_ID}/edit#gid=0, this should be a long list of alphanumeric characters, keep this for later.
  4. Now at the bottom of your google sheets page, there are tabs to switch between data sheets, we now need the name of the data sheet your want to import, by default it is Sheet1.
  5. Using the past two string DOCUMENT_ID and SHEET_NAME, and replace the following url with these https://docs.google.com/spreadsheets/d/{DOC_ID}/gviz/tq?tqx=out:csv&sheet={SHEET_NAME}
  6. On the New Importer screen, for the datasource option select Remote URL, and enter the URL from the previous step into the field, now when you submit the page and create the importer it will download a copy from this url, along with every time you run the importer it will download a fresh copy before importing.