How to Export WordPress Data to CSV/XML

How to Export WordPress Data to CSV/XML

WP All Export turns WordPress data into custom spreadsheets and XML feeds. First, select the data to export. Then, drag & drop to set up the export file, deciding exactly what gets exported and how the data gets formatted.

You can export WordPress posts, pages, WooCommerce products, orders, ACF fields, users, and custom post types from any theme or plugin. Export all custom fields, images, attachments, and taxonomies (categories or tags). You can schedule exports using cron jobs or via our Automatic Scheduling Service.

Create unlimited combinations of filters to control exactly which records get exported. Connect with external apps using the Zapier integration. Run custom PHP code. Run exports using WP_Query. Enable Client Mode on specific exports.

File Types

Export to CSV/Excel, simple XML, or to a custom schema XML.

Filters

Learn how to filter the exported WordPress data; single and multiple filters can be used.

Standard Post Data

Learn how to export the standard WordPress post data into CSV or XML.

Custom Fields

Learn how to export custom fields from any other plugin or theme using WP All Export.

Images & Attachments

Learn how to export images and attachments from WordPress to CSV or XML.

Categories & Tags

Export taxonomies directly, or export taxonomies along with posts.

WooCommerce

Export WooCommerce products, orders, customers, reviews, coupons. Export products to the Google Merchant Center.

ACF

Export fields from the Advanced Custom Fields plugin. All regular ACF fields are supported (text, picker, media, taxonomies, etc).

Users

Learn how to export WordPress users to CSV or XML.

Comments

Learn how to export WordPress comments to CSV or XML.

Settings

Learn more about WP All Export's settings and options.

Scheduling

Learn how to schedule imports using cron jobs or our paid Automatic Scheduling Service.

External App Integration

Learn how to connect with external applications (such as Gmail, Google Drive, etc) using Zapier.

Advanced Topics

Custom export fields, custom PHP functions, Client Mode, and WP_Query exports.

How to Send Exported WordPress Data to Zapier

How to Send Exported WordPress Data to Zapier

Zapier acts as a middle man between WP All Export and hundreds of other popular apps. You can automatically add export files to Dropbox or Google Drive, email them somewhere with Gmail, or anything else you can think of. Here's the full list of apps: http://zapier.com/zapbook/wp-all-export-pro/

You can save your WP All Export Pro export files to Google Drive or Dropbox when your export finishes. You can also send your export files via email. Note that Zapier can only process your export file, but not the data contained inside the file.

Connect Zapier and WP All Export

Go to Zapier.com, create an account, and make a new Zap. Then select WP All Export as the trigger app and whatever you want as the action app.

When an export is successfully completed WP All Export will send Zapier some information like the export file』s URL, the post types exported, the number of records in the export file, etc.

When creating your Zap you can set up filters so it only runs when a specific export is completed, or if this is an export of WooCommerce orders, or if it contains more than 100 records, or whatever you want.

Step 1: Customize Your Export

Create and set up your custom WordPress export as desired. In this example, we will send our export file to an email, but the process is the same for any other trigger used within Zapier.

Step 2: Connect With Zapier

In Zapier, select Make a Zap, choose WP All Export Pro as the app, and New Export File as the trigger. Then, click on Continue:

If you haven't linked your WP All Export account yet, Zapier will ask you to sign in. To connect your site to Zapier, you will need your site's URL and your API key, which can be found in All Export › Settings.

Once connected to the correct site, Zapier will ask you to test the trigger with a recent export. After the trigger is set up, you can select the action that will happen whenever there's a New Export File in WP All Export:

Every time that the export runs, the trigger will execute and perform the action as configured inside Zapier. You can learn more about using Zapier: https://zapier.com/learn/getting-started-guide/what-is-zapier/

Importing Images From Your Server

Importing Images From Your Server

Importing images that already exist on your server is exactly the same as importing images from a URL, except you only need to specify the file name of the image.

The images you are importing must be uploaded to /wp-content/uploads/wpallimport/files/

The images in this folder will be copied to the paths used by your WordPress Media Library when the import is run – typically, /wp-content/uploads/YYYY/MM/.

How to import any CSV/XML to WordPress.

How to import any CSV/XML to WordPress.

Setting up an import for thousands of posts is very similar to manually creating a post. You create a template for your posts that WP All Import uses when importing your data. To set add data from your import file to your import template, you simply drag and drop it.

Step 1: Upload Your File

The first step to creating an import is to upload your import file. You can choose to upload the file from your computer, paste in a URL to the file, or choose an existing file that you've already used with WP All Import.

Next, choose either New Items or Existing Items. If you are importing data from your file into posts that are already in your site, select Existing Items. Otherwise, select New Items.

Finally, you need to decide what you want to import. You can import posts, pages, taxonomies, users, or custom post types added by other themes and plugins like WooCommerce products or real estate properties.

Step 2: Review Your Data

WP All Import will process your file and prepare it for import. If you uploaded a CSV, check that the correct delimiter was used. If you uploaded an XML file, check that the correct node was selected.

If you only want to import some of the records in your import file you can add filter rules.

Step 3: Configure Your Import

Every column or element from your import file will be displayed on the right. On the left you have your import. WP All Import will create posts using the import template you create here. Simply drag your import data from right to left. You can fill in as much or as little of the fields as you like depending on your needs.

Step 4: Choose Which Data to Update

Here you can tell WP All Import how to handle each specific piece of data. For example you can have it only add new images to posts, or just update the stock and price for your products.

You can also configure this import to run on a schedule, and other advanced options.

Step 5: Confirm & Run Import

Now it's time to run your import.

How to Export ACF Fields

How to Export ACF Fields

WP All Export along with the ACF Export Add-On allows you to export data from any Advanced Custom Field(s) present in your post type or custom post type.

The Advanced Custom Fields plugin extends basic custom fields to enable more complex fields, different layouts, and settings. WP All Import has an integration with the ACF plugin to export the information stored in such fields.

Export ACF Text Fields

Export basic ACF text fields such as text area, number, range, email, URL, password, etc.

Export ACF Picker Fields

Export ACF picker fields such as date picker, date time picker, time picker, and color picker.

Export ACF Media Fields

Export ACF media fields such as image, file, oEmbed, gallery, or even a Wysiwyg editor.

Export ACF Choice Fields

Export ACF choice fields such as select, checkbox, radio button, button group, etc.

Export ACF Taxonomy Field

Export ACF taxonomy fields using drag and drop.

Export ACF Google Map Fields

Export ACF google maps fields with the address, latitude, and longitude information.

Export ACF Relational Fields

Export ACF relational fields such as link, post object, page link, relationship, etc.

Export ACF Repeater and Group Fields

Export ACF repeater and group fields easily.

Export ACF Flexible Content Fields

Export ACF flexible content fields.

How to Map Custom Fields

How to Map Custom Fields

Mapping is used when the value you need imported to your site is different than the value in your file. A visual interface is available for mapping for Custom Fields and Custom Taxonomies. To map elsewhere, you can use a custom PHP function.

Visual Mapping Tool

For example, you may have a file with product categories that are written in Dutch, but you want to import these products to categories that already exist on your site with English names.

Or, your theme or plugin requires the value of a Custom Field it uses be either 1 or 0, but in your XML or CSV file, the values are expressed as Yes or No.

You need to map the values in your file to the values you actually imported to your site.

Example – Mapping For A Dropdown

In the previous article, Importing to Theme & Plugin Fields, we explained how to detect the fields used by your theme or plugins, and their possible values.

Our theme has a dropdown to specify whether a Property Listing is for rent, or for sale.

Rent or Buy Example

The field name is 「rob_value」, and the possible values, as stored in the database, are 「Rent」 and 「Buy」.

Field Example

Note: You can see the values as they are stored in the database by clicking inside the Value textbox for the 「rob_value」 field in WP All Import. The values stored in the database may not be the same as values shown inside the select box in the theme. We must map to the values as they are stored in the database.

Our XML file has a element that is set to FORSALE if the property is for sale (Buy), and FORRENT if the property is for rent (Rent).

XML Data

Without mapping, simply dragging & dropping to the Value box for rob_value would not work, because the value of is not correct for our theme.

To solve this problem, we use the Mapping feature.

Mapping

Click Field Options… and then click Mapping.

A dialog box will pop up allowing you specify the mapping rules.

Mapping Rules Example

Now, when the import is run, FORSALE in your file will be translated to Buy, and FORRENT in your file will be translated to Rent, so your data will be imported correctly, as per the requirements of your theme and plugins.

Serialized Fields

Serialized Fields

If you aren』t a developer and don』t know what 「serialization」 is, this article will probably be over your head.

Developers, read on…

In very rare cases, some themes store multiple data points in a single field. Themes shouldn』t do this. It』s not nice, and the practice is generally frowned upon. But, some do. These fields are often called 「serialized」 fields.

Serialized Selected

Serialized Dialog

You can either use the serialization feature in WP All Import to import the key and value pairs, or you can use a custom PHP function to return the value in the proper format needed by your theme or plugin.

The Serialize feature generates an array with the key => value pairs you specify, and then returns the serialize()』d value of the array.

Overview

Overview

In this tutorial you』ll learn how to use WP All Import to import data from your XML or CSV into any plugin or theme.

Many themes and plugins have 「custom」 places to enter in data – not just the post title and content boxes on normal Posts or Pages.

The technical term for these extra fields is Custom Fields or post meta.

WP All Import has full support for Custom Fields and can even auto-detect the names of the fields used by your themes and plugins so you don』t have to ask the author, guess, or look at any code.

Watch the video tutorial below to see how easy it is:

Auto-Detecting The Fields

For WP All Import to detect a field, it must exist at least once in your database in a published post (not draft or any other post status).

If you already have posts on your site that have the fields you want to import to filled out, WP All Import will detect the fields.

If not, simply create a dummy post, enter in dummy values for the fields you want to import data to, then publish it.

Click See Detected Fields to see the detected fields.

See Detected Fields

Once you click See Detected Fields, WP All Import will show you all of the detected fields.

Populated Detected Fields

WP All Import can also show you the different possible values for your fields. So for example, if you need to know what the possible values of a 「select」 option is, just manually create a post with the 「select」 option in every state you want to know the field value for.

Example – Select Box In OpenDoor Theme

Rent or Buy Select Field

Saving two posts, one with the select set to 「Rent」 and the other with the select set to 「Buy」, results in WP All Import auto-detecting the possible values:

Of course, you can import to fields without WP All Import auto-detecting their names and values – you just have to know the names and possible field values yourself.

How to Pass Exported WordPress Data Through PHP Functions

How to Pass Exported WordPress Data Through PHP Functions

You can use PHP functions to process your WordPress exports in WP All Export with the following steps:

Add or drag in the export fieldClick the field to edit it.Save your function in the Function Editor.Enable "Export the value returned by a PHP function" and type in the function name.Save the field.

Use PHP to process WordPress data while it's exported

WP All Export has the ability to process the data in any export field with PHP functions. You can write a custom function to process your data, or use a native PHP function to do it.

First, click the Add Field button under the export template and then select the field from the Select a field to export drop-down list. You can also click an existing field to bring up the edit export field modal.

From the edit export field modal, enable Export the value returned by a PHP function:

Export the value returned by a PHP function option.

In the example above, the Title is being exported. In this case, the title will be passed to your function as the first and only argument:

function my_process_title( $title ) {
// do something with $title
// return it
}

Using native PHP functions on export fields

In the your_function_name text box, you can use any native PHP function that uses one argument. For example, if you wanted to make the Title export field export all of the titles in uppercase, you could use strtoupper():

In fact, you can use any function that exists and is accessible during the export. That includes WordPress functions like wp_get_attachment_url, sanitize_title, etc.

Using custom PHP functions on export fields

For more complicated cases, you can write full-featured PHP functions inside the Function Editor.

As an example, let's say that you're exporting data from a real estate theme like WP Residence and you want to export the property gallery image URLs for each exported property. They're stored in the image_to_attach custom field as IDs. If we were just to export that custom field, we'd get this:

35,39,37,41,43,

We could use this function to extract the IDs, get the attachment URLs, then return a delimited list of the URLs:

function my_convert_ids_to_urls( $ids ) {
// Return nothing if there are no IDs.
if ( empty( $ids ) ) {
return null;
}

// Turn the IDs into an array of IDs.
$ids = explode( ',', $ids );

// Convert the IDs to attachment URLs.
$urls = array_map( function( $id ) {
return wp_get_attachment_url( $id );
}, $ids );

// Get rid of empty array elements.
$urls = array_filter( $urls );

// Return comma-delimited list of image URLs.
return implode( ',', $urls );
}

Let's use this function with the image_to_attach export field from WP Residence:

Using image on the image_to_attach field.

And that's it. Our export file will contain a column labeled Image Gallery URLs, and each row in that column will contain a comma delimited list of image URLs for the images in that property gallery.

Head over to https://www.wpallimport.com/documentation/developers/code-snippets/ for a full list of code snippets to get you started.