Documentation / How To Guides

How to import WordPress Pages with Hierarchy from CSV file

Overview

This guide will take you through importing data from a CSV file into WordPress Pages, this same method can be applied to importing Posts, Pages, and Custom Post types.

The CSV file we are importing doesnt have to follow a specific structure, as ImportWP allows you to choose which parts of data from the CSV file link up data on pages.

Creating the WordPress Page Importer

To create an importer click on ImportWP menu icon from within the wordpress admin area, this will show a list of all the importers that have been created. Click the Add New button that is displayed at the top of the screen. Once loaded you should see a form that allows you to choose what and how you are importing, from the dropdown labelled Import Template choose Page from the list.

In this example we will be uploading the example list of pages csv file. You can follow along using this file, or use your own. So choose Uploaded File from the list of Where is the data being imported from. For the last question Setup datasource select the file with the data you wish to import.

Click the continue button at the bottom of the screen to upload the file and start selecting which parts of the file belong to page data.

Configuring general import settings.

The general tab of the importer settings section allows you to configure the csv delimiter (delimiter is the seperator which defaults to a comma) and enclosure (enclosure can vary depending on which software you used to export the csv from). In general settings you can set which record you wish to import from (for this page import i had to change this to row number 2 due to avoid the headings), and how many records to import (leave it at 0 to import everything).

Now for the importer permissions, if you filled out the permissions during setup you can skip this section. We will only give insert permission to the csv importer so that if a page already exists on the system with the same details it will not be overwritten, to do this click on the permissions tab and select only the checkbox labelled create.

Mapping data to WordPress Page fields

Now we have the importer setup, lets map the csv columns to the page template. To do this click on the button to the right hand side of the template field to start the visual column selector.

A modal window should appear with a table showing the first 5 rows of the pages csv file. Click on the column you wish to use, and the selection should appear at the bottom of the modal it should look something like {3} , and a example of the selected chosen data will be output to right of the word preview (you can manually edit the selection in the selection textbox). Once you are happy with the selection click on the submit button to close the window and save the selection.

In this example we are going to import a page hierarchy, by default the parent page is populated by a dropdown, you can customise this to allow manual selection from the csv file along with many other fields, to enable which fields you want to map data to click on the settings tab within the templates field section. Check the Enable parent field option, and choose from the value dropdown what field you are using to set the page parent.

Once you have enabled/disabled the extra fields, go back to the Fields tab and select the page parent column via the selector modal.

With all the approiate fields selected we are ready to run the importer.

Running the WordPress Page import

Once all fields have been setup, you can preview how the data will look by pressing previous/next to loop through the files records under the heading Preview Settings (the preview for each field will be displayed under the field in the template).

To start the import click on Save & run, this will open up the importer screen. Click on Run Import to start the import process, the table should populate with information about all the pages imported, if you accidentally leave the page, you can resume the import by loading up the importer and clicking on the continue import button.

If all has gone well, all the pages should have been imported.