How to Programmatically Create Pages From a CSV File in WordPress in 2023

Bulk create Pages in WordPress Hero Images
LPagery Logo

You have a CSV file with data you now want to import into WordPress? We take you through the whole process of doing exactly that in this tutorial. 

Let’s say you are working on a website for a company with multiple stores at multiple locations and don’t want to create and edit each page for every store manually. 

If you have the data of each individual store in a spreadsheet like Excel, Google Sheet or any other program that lets you create CSV files, you can then use the LPagery WordPress plugin to create pages automatically for each row in your spreadsheet.

Let me show you exactly how this works:

YouTube

Mit dem Laden des Videos akzeptieren Sie die Datenschutzerklärung von YouTube.
Mehr erfahren

Video laden

How to Programmatically Create Pages from a CSV File in WordPress

Some of the functionalities presented in this article are not available in the free version

Step 1: Download LPagery from the WordPress Repository

While we offer a premium version of LPagery, you don’t necessarily need it to bulk create local landing pages with WordPress.

To download the free version of LPagery you simply need to:

Go to your WordPress dashboard and head over to the ‘Plugins -> Add new’ section and search for ‘LPagery’. Alternatively you can download it here: https://wordpress.org/plugins/lpagery/

Step 2: Set up a CSV/XLSX File

After installing LPagery, you will then need to create your source file for pages you want to create. You can do this with any software that lets you create CSV or XLSX files.

In the top row of the spreadsheet you fill in one placeholder per column:

CSV Example Step 1

The example above will give you the following placeholders:

{city}, {service} and {your-placeholder}

next:

Fill in your data

Next up you will have to add your data to the spreadsheet. Keep in mind:
Every row will equal one generated page later on.

CSV Example Step 2

Step 3: Create the Template Page using Your Pagebuilder of choice

The example above will give you the three pages. If you have a heading on your template page with this content:

„Your {your-placeholder} {service} service in {city}

The result pages would be:

„Your best Plumbing service in New York

„Your professional Plumbing service in London

„Your excellent Plumbing service in Tokyo

For LPagery to work you will need a template page. Simply follow these steps to set it up:

1. Create the Template Page

If you want to use an already existing page, simply ignore this step and move on to the next step.

First, you will have to create a new regular WordPress page. Go to ‚Pages‘ in the admin bar on the left and click ‚Add New‘. Now edit the page with your pagebuilder of choice just like you would any other page.

2. Adding Placeholders/Dynamic Content

To make the template page dynamic and able to adapt to your desired content, you need to add placeholders on the site, which you determine while creating a CSV File.

For example: If you have set up a CSV File with the following Placeholders:

  • your-placeholder
  • service
  • city
CSV Example Step 1

You can then use the placeholders like this:

“Your {your-placeholder} {service} service in {city}“ as a heading on your page.

Then three pages would be generated and the content would be changed to:

„Your best Plumbing service in New York

„Your professional Plumbing service in London

„Your excellent Plumbing service in Tokyo

3. Use the Template Page

When you are done with preparing the template page, simply publish the page and afterwards you will be able to select the page in LPagery as template page.

Select Template Page Screenshot

Step 4: Change URI Slug and Assign Categories/Parent Page (Only LPagery Pro)

With LPagery Pro you have some options after you created and selected your template page. You can change the URI slug of the created pages, assign a category and a parent page, as well as selecting the status of the created pages (Published, Private, Draft).

Customize the URI Slug

Per default LPagery will add the title of the template page as the URI slug. You can leave this as is, if you want to have the page title as slug. If you want to customize the URI you can do this using the same placeholders you used on your template page. For example:

my-service-in-{city}

as input in the URI field, would result in

„www.your-domain.com/my-service-in-city/

(„city“ would be replaced with whatever cities you have in your CSV file or are detected with the radius option)

Adding a Parent Page

You can select a parent page for the created pages so the created pages will then be child elements of your parent page.

If you decide to connect the generated pages to a parent page, the slug of the parent page will automatically be applied to the URI of the newly generated pages. If we added a parent page to the example above, which has the slug „services“, the URI would look like this:

„www.your-domain.com/services/my-service-in-city/„

Assign a Category

LPagery has a built in category function, which enables the WordPress categories to not only work on posts but also on pages. This way you are able to create a category and then assign your created pages to this category. This way you can ensure a good website structure.

Assign category

Step 5: Select your Input Type

If you are using the free version of LPagery, you only have the option to upload a CSV or XLSX file. Simply select your source CSV/XLSX file and you are good to go.

If you are using LPagery Pro you have more options to choose from. Of course you can also use a CSV/XLSX file and this option might be the best one for most occasions but you can also link to a Google Sheet URL the Google Sheet structure is exactly like the structure of a CSV file mentioned before.

Make sure that LPagery can access your Google Sheet.

If you want to create pages automatically for cities in your area, select the ‘Radius’ option. Now you can modify a couple of options. Also make sure that you use the placeholder {city} on your template page, as this is the placeholder which will then be replaced by the cities around your business location.

Step 6: create the Pages

When you are done with the setup, just click on ‘Next’. In the Popup you will then see all pages that will be created (Every row represents one page) and with LPagery Pro you will be able to make changes to the pages via the popup (e.g. deleting rows or adding new rows and collums).

Then click ‘Generate Pages’ and all pages will be generated. This can take some time depending on the size of your template page and amount of created pages.

creating Pages in Bulk can be useful for everybody
It doesn’t matter if you are running a small local business, a blog, an online shop or even a huge marketing agency. LPagery offers a helpful solution for everyone who wants to save time and optimize their online marketing efforts by bulk creating local landing pages in WordPress.

Table of Contents

Pro Feature

When to Use This Feature

Use Examples