When coming from a non-WordPress environment, it is important to provide data exports in a standard format that will allow us to import them successfully. You can use the format below to import data.
Comma-separated values
Comma-separated values files are one of the more popular and standard ways to migrate data. The CSV format allows for easy import and can be templated and repeated when it comes time for additional data imports. You will need to provide a few discrete templates. The list below includes the column names and data types that are expected.
Column names are in bold. If a column is optional and you don’t have data to fill it, still include the column without the data. Do not remove it.
The preferred date format is YYYY-MM-DD HH:MM:SS for all dates.
Example: 2023-04-03 13:34:12
Posts Table: post.csv
- GUID: This is a global unique identifier, in integer format. This should be a key or ID that identifies a post or article.
- Post Title: This is the title of the post, in string format.
- Post Body: This is the main content of the post, in long text/string format. Please do not use HTML in the post body. Certain tags like
<p>,<b>, and<i>are allowed, but please strip out all other HTML. - Publish Date: This should be the date the post is published, in date format.
- Last Revised: This is optional, the date the post was last edited, in date format.
- Author Email: This is the email address of the author, in string format. If there are multiple authors, please separate them using a semicolon character.
- Category: Include a human-readable category name, in string format. If there are multiple categories, the first category found will act as primary category. Separate each category using the semicolon character.
- Tags: Include human-readable tag names, in string format. Separate each tag using the semicolon character.
- Read Count: This is optional, a simple counter for the amount of times a post has been read, in integer format.
- Summary: This is optional, the summary of the post in long text/string format.
- Excerpt: This is optional, the excerpt of the post in long text/string format.
- Subtitle: This is optional, the subtitle of the post in long text/string format.
- Featured Image: This is optional, the full URL path to the image in string format if web-accessible, or the relative path to the image from the root folder if you’re providing images via ZIP file.
- Allow Comments: This is optional, a string specifying a “yes” or “no” value, depending on whether comments should be allowed on the post
- Template: This is optional, in string format. Newspack has a few discrete page templates you can assign to a post. The options are
default,one-column, orone-column-wide.
User Table: users.csv
- GUID: This is a global unique identifier, in integer format. This should be key or ID that identifies a user account.
- Email Address: This is the public email of a user, in string format.
- User Name: This is optional, in string format. Usernames only allow A to Z and 0 to 9 characters
- First Name: This is optional, in string format, the first name of a user. It will be used in their display name.
- Last Name: This is optional, in string format, the last name of a user. It will also be used in their display name.
- Facebook URL: This is optional, a string format with the full Facebook URL of the user.
- X Username: This is optional, a string format with the X/Twitter username of a user.
- YouTube URL: This is optional, a string format with the full YouTube URL of a user.
- LinkedIn URL: This is optional, in string format, the full LinkedIn URL of a user.
PHP Setup
If you are using PHP on your server, the best way to configure these files is to build a nested array and use the fputcsv() php function to save. Your server might be different, but here is the general overview.
foreach($articles as $key => $data)
{
$post[$key]['GUID'] = $data['id'];
$post[$key]['Post Title'] = $data['post_title'];
$post[$key]['Post Body'] = $data['post_body'];
...
}
$fp = fopen('posts.csv', 'w');
foreach ($post as $key => $fields) {
fputcsv($fp, $fields);
}
Pre-Launch Table of Contents
