Exporting your WordPress content
How to export your WordPress site's content (posts, pages, and other text-based content), your media library and metadata (alt text and descriptions), and all of your custom fields.
Before we start moving your content to CloudCannon, we need to get all your WordPress data exported. Following the ‘moving house’ analogy, you might think of this as carefully packing up the different types of items from your old house — some things go in boxes, others need special wrapping, and everything needs to be labeled.
We’ll handle this in three main steps: first, we’ll export your basic content (posts, pages, and other text-based content) using WordPress’s built-in tools. Then, we’ll tackle your media library, making sure we preserve all your images and files along with their important metadata like alt text and descriptions. Finally, we’ll export any custom fields you might have, ensuring we don't leave behind any crucial piece of content.
Don't worry if this sounds like a lot — we can automate much of this process.
WordPress export
Let's start with the core of your website — your posts, pages, and other content. WordPress makes this part relatively straightforward with its built-in export tools. We can use either the WordPress Admin interface or WP-CLI, depending on your comfort level with command-line tools. For larger sites, I recommend the WP-CLI approach as it's more reliable and can handle bigger exports without timing out.
Basic content export
- Via WordPress Admin:
- Go to Tools → Export
- Choose “All content”
- Download export XML file
- Via WP-CLI:
wp export --dir=exports/ --all
Media library export
- Export your media library files:
# Create media export directory
mkdir media_export
# Copy uploads directory
cp -r wp-content/uploads/* media_export/
# Create media manifest
find wp-content/uploads -type f > media_manifest.txt
- Generate media metadata:
SELECT
post_title,
guid,
post_mime_type,
meta_value as 'alt_text'
FROM wp_posts
LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
WHERE post_type = 'attachment'
AND meta_key = '_wp_attachment_image_alt'
INTO OUTFILE 'media_metadata.csv';
Custom fields export
If your WordPress site uses custom fields (like those created with the popular Advanced Custom Fields plugin), we need to make sure we bring these along too. We'll export both the field definitions and their content, making sure we preserve the structure and relationships that make your content unique.
Exporting ACF fields
If you use the ACF plugin, run the following PHP using wp eval
:
// Export ACF field groups
$field_groups = acf_get_field_groups();
$export_data = array();
foreach ($field_groups as $group) {
$fields = acf_get_fields($group['key']);
$export_data[$group['key']] = $fields;
}
file_put_contents('acf-export.json', json_encode($export_data, JSON_PRETTY_PRINT));
Exporting custom field data
If you have any other custom fields, it’s a good idea to keep a full record of them. Run the following SQL on your database:
SELECT
p.post_title,
p.post_type,
m.meta_key,
m.meta_value
FROM wp_posts p
JOIN wp_postmeta m ON p.ID = m.post_id
WHERE m.meta_key NOT LIKE '\\_%'
INTO OUTFILE 'custom_fields.csv';
Great! Now you have a copy of all of your WordPress data.
In our final step, we'll process your content to turn it to file formats we can work with.
Lessons in this Tutorial
WordPress migration guide
- Preparing your WordPress migration
- Exporting your WordPress content
- Processing your WordPress content