Currently Available: Need a skilled Software Developer for your next project?
Categories
WordPress

Generating WordPress Pages in Bulk from Google Sheets

When page details are already in Google Sheets, use each row to create a WordPress page. A plugin can import the rows. Or a custom script can read the sheet and send page data to WordPress through its REST API, which lets other software make requests to the site.

Decide how the integration will handle each row: which rows to use. Decide what to do if a page already exists. Choose whether WordPress should save new pages as drafts or publish them. Set those rules before importing. A small draft test lets you check the page layout and content before you create or publish a larger batch.

Choose how each row becomes a page

A spreadsheet row should represent one page, or provide the values needed to fill a shared page template. For example, one row might contain a page title and URL slug, along with body content and a status. A slug is the part of a page’s URL that identifies it, such as example-service; a template is a reusable layout with places for row-specific details.

A practical sheet might include columns for an action flag, title, slug, and content. It might also include status and parent page ID. Keep the WordPress page ID and result in separate columns. The action flag lets you mark rows as ready without importing every row. WordPress returns a page ID when it creates a page. Save that ID in the sheet so later runs can find the same page.

Keep the sheet’s values consistent. For example, use the same spelling for each action flag and status, and leave required fields blank only when your integration knows how to handle that case. If a page belongs under another page, use the parent page’s WordPress ID. WordPress’s page endpoint accepts title, content, and slug fields. It also accepts status, parent, template, and featured image fields.

Pick a plugin or write an integration

Use a page-generation plugin when pages share a layout and only a few details change. The MPG plugin listing describes using spreadsheet data and template placeholders to create pages. Check the current documentation to see how the plugin accesses the sheet and what page limits apply. Also check what happens when a row changes or disappears; product features and plan limits can change.

Use an importer when each row already has values that match WordPress fields. For example, one column can provide the title and another the page body. The WP All Import listing describes importing Google Sheets data through a public sheet URL. The SteadyPost listing describes direct sheet imports along with features such as previews and scheduled re-imports. These are product-specific descriptions, so verify that the current version supports the page type, sheet access method, and update behavior you need.

A custom integration makes sense when you need specific validation, page-matching rules, or logging that a plugin does not provide. A script can read the sheet, check each row, and send page requests to WordPress. The trade-off is that the person maintaining the script must also handle errors, credentials, retries, and duplicate prevention.

Send one page request for each ready row

For a custom integration, Google Sheets can return values from selected groups of cells through the Sheets API batch read method. Google recommends batching API calls when practical to reduce the number of separate network requests. That advice applies to reading or writing spreadsheet data; it does not create multiple WordPress pages in one request.

WordPress documents page creation at POST /wp/v2/pages. A script typically sends a separate request for each page. A simplified request body looks like this:

{
  "title": "Example service in Example City",
  "slug": "example-service-example-city",
  "content": "<p>Page content goes here.</p>",
  "status": "draft"
}

The draft status gives a reviewer a chance to inspect the page before publication. WordPress also accepts publish as a status, but publishing directly from a spreadsheet removes that review step. Start with drafts until you have checked the output on the actual site, including links, images, page layout, and mobile display.

Google Apps Script can make the HTTP request with UrlFetchApp. WordPress Application Passwords give a script or external service one way to prove its identity to WordPress. Create a separate password for the integration. Send requests over HTTPS. Use a WordPress account with only the permissions the integration needs. WordPress lets administrators revoke an Application Password separately from the account’s main password.

Make reruns update the right page

Decide what the script should do with each row every time it runs. Without a rule for identifying the page that matches a row, the script may create a duplicate instead of updating the existing page. The simplest reliable approach is to save the returned WordPress page ID in the sheet and use that ID for later updates.

If the integration cannot store page IDs, it needs another reliable way to connect each row to its page, such as checking for a unique slug before creating a page. Test the rule with a small sample: run the same rows twice and confirm that the second run updates or skips existing pages as intended.

Record each row’s outcome in the sheet. Store the page ID or URL when WordPress succeeds, and an error message when it fails. Record results for each row because some requests in a batch can succeed while others fail. A useful error record tells you which row to inspect and whether the script should retry it.

Validate content and protect access

Check required fields before sending a request. A missing title or incorrectly formatted value should stop the script from sending that row. It can still send other valid rows. Test a normal row, a row with line breaks or special characters, and a row that sets a parent page. Confirm that the page visitors see matches the content and layout you intended.

A column in Sheets does not automatically become a writable WordPress field. The WordPress site may need to register custom fields, also called metadata, before the REST API can expose them. WordPress explains the requirements for exposing custom fields through the REST API. If a field does not appear or save as expected, check whether the site has registered it for REST API use and whether the user has permission to access it.

Protect the sheet and the integration credentials. A link-shared spreadsheet gives anyone with the link access under its sharing settings. A private sheet requires the integration to prove it has permission before reading the data. If Apps Script stores configuration in script properties, restrict who can edit the script and its settings; Properties Service stores settings as named values, but it is not a dedicated secrets vault.

Finally, review whether each generated page offers useful, distinct information. Creating many URLs does not establish that the pages will rank or help readers. Check factual accuracy, repeated wording, and whether each page gives visitors a clear reason to exist.

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *