When you use the WP All Import and the WP All Import – Toolset Types Add-On plugins you can import your posts from a CSV file and maintain relationships between your post types.

You can create connections between posts that form:

  • one-to-one,
  • one-to-many,
  • and many-to-many relationships.

Imported posts will be connected to the posts that already exist in your site.

In order to connect posts, use the Relationships section of the Import CSV/XML screen and drag-and-drop the column(s) from your CSV file that represents (s) the post title you want to connect to.

Instead of the post title, you can also use the post slug or id.

Relationships section

Let’s see the details for different scenarios.

Example #1 – one-to-one relationships

Suppose you have two post types in your site:

  • Speakers
  • Presentations

and the one-to-one relationship between these post types.

One-to-one relationship
One-to-one relationship

Now we want to import the following CSV files:

Speakers CSV file
Speakers CSV file

Download Speakers.csv

Presentations CSV file
Presentations CSV file

Download Presentations.csv

And we want to establish a connection between Presentations and Speakers.

Note that the second file (Presentations) includes an extra column (marked in blue) that identifies the speaker post. We will use that column to establish the relationship during the import.

Steps to be done

  1. Import the Speakers file. This is a regular import for adding new posts.
  2. Import the Presentation file. Use the extra column (speaker) to connect presentations with existing speaker posts. Simply drag and drop the speaker field into the Relationships area.

 How to establish connections between posts
How to establish connections between posts

After the import, the presentation posts will be created and each will be connected to the relevant speaker.

Single presentation post
Single presentation post

Example #2 – one-to-many relationships

Suppose you have two post types in your site:

  • Movies
  • Directors

and the one-to-many relationship between these post types.

Movie-Director relationship
Movie-Director relationship

Now we want to import the following CSV files:

Movies CSV file
Movies CSV file

Download Movies.csv

Directors CSV file
Directors CSV file

Download Directors.csvv

 

And we want to establish a connection between Movies and Directors.

Steps to be done

  1. Import the Movies file. This is a regular import for adding new posts, which doesn’t involve the post-relationship since for this moment there are no directors on our site. The director column (G; marked in grey in the screenshot above) won’t be used during the import.
  2. Import the Directors file. Use the extra columns (Movie 1, Movie 2, Movie 3) to connect directors with existing movie posts. Simply drag and drop the Movie 1, Movie 2, Movie 3 fields into the Relationship area, one per line or separate with a delimiter.

Importing directors
Importing directors

After the import, the director posts will be created and each will be connected to the relevant movies, in some cases, the same director will be assigned to more than one movie.

Single director post
Single director post

Please note that you can also change the order of importing your files and import the Directors file first and the Movies file next.

In this case, you can ignore the additional Movie columns (D,E,F) from the Movie file and use the Director (G) column as the connector, in the Relationship section.

Example #3 – many-to-many relationships

Suppose you have two post types in your site:

  • Events
  • Artists

and the many-to-many relationship between these post types.

Events-Artists relationship
Events-Artists relationship

Now we want to import the following CSV files:

Events CSV file
Events CSV file

Download Events.csv

Artists CVS files
Artists CVS files

and we also want to establish connections between events and artists as follows:

Artists and Events
Artists and Events

Steps to be done

Instead of using the Artists-Events file, we need to add additional columns to the Artists CSV file, that will represent the Event posts.

So the Artist CSV file, which we will eventually use for the import, will look like this:

Artists file with additional columns
Artists file with additional columns

Download Artists.csv

Now we are ready to import the data.

  1. Import the Events file. This is a regular import for adding new posts, which doesn’t involve the post-relationship since for this moment there are no events on our site.
  2. Import the Artists file. Use the extra columns (Event 1, Event 2, Event 3) to connect artists with existing event posts. Simply drag and drop the Event 1, Event 2, Event 3 fields into the Relationship area, one per line or separate with a delimiter.

Importing artists
Importing artists

After the import, the artist posts will be created and each will be connected to the relevant events, in some cases, the same artists will be assigned to more than one event:

Single artist
Single artist

And also, a given event might be connected to more than one artist:

Single Event
Single Event

Many-to-many relationships that use the intermediary post type are not supported by the WP All Import plugin. If you need this kind of support please let us know.

Updating existing posts

Thus far we’ve been importing new posts. You can also update existing posts. The process is the same. The only difference is that in the first screen of the import process you choose the Existing Items option:

Updating existing items
Updating existing items

If your CSV file includes new columns that represent new relationships, the existing posts will be updated and new connections will be established.

So, for example, to connect an existing director post with one more movie, you simply need to put the “new” movie title in another column (Roxanne, in our example). Note, that the movie needs to exist on your site.

Updating existing posts and connecting to one more post
Updating existing posts and connecting to one more post