
How to import and export content in WordPress?
To export content in WordPress, go to Tools > Export, choose whether to export all content or just posts, pages, or media, and click Download Export File. WordPress creates an XML file (in the WXR format) containing your content. To import it into another site, go to Tools > Import, install the WordPress importer, upload the file, assign authors, tick Download and import file attachments, and run the import.
The built-in import and export tools are perfect for moving content between WordPress sites, merging blogs, or keeping a portable copy of your posts. They're not the same as a full site backup or migration, though, and knowing the difference saves a lot of frustration. This guide explains what the tools include, how to export and import step by step, how to handle media and large files, how to use WP-CLI, how to import from CSV and other platforms, and how to fix common errors.
What Does WordPress Export Include?
The export tool creates a WXR (WordPress eXtended RSS) file, which is an XML file that describes your content. It includes:
- Posts, pages, and custom post types (if they're set to be exportable)
- Categories, tags, and custom taxonomy terms
- Comments
- Custom fields (post meta)
- Authors (names and usernames)
- Navigation menus and menu items
- Media attachment records, including their original URLs
- Synced patterns and some other block editor content that WordPress stores as posts
What It Doesn't Include
This is where people get caught out. The export file does not include:
- Your actual media files (only references and URLs to them)
- Themes and plugins
- Site settings from Settings screens
- Widgets in classic themes and Customizer settings
- Plugin-specific data stored in custom database tables
- User passwords, roles, and most user profile data
If you need to move everything, including your theme, plugins, settings, and files, you need a full migration or backup plugin instead. We'll cover when to use each approach below.
When to Use Import and Export
The built-in tools are ideal when you want to:
- Move content to a new site with a fresh design or different setup.
- Merge two blogs into one.
- Split a site, for example moving one category to a separate site.
- Set up a staging or test site with real content but none of the old settings.
- Keep a portable copy of your writing in an open format.
- Load demo content for a theme.
For moving an entire site to a new host or domain, a migration plugin is usually faster and more complete.
How to Export Content From WordPress
- Log in as an Administrator: Only users with the export capability can use the tool.
- Open the export screen: Go to Tools > Export.
- Choose what to export:
- All content: Everything that can be exported, which is the most common choice.
- Posts: Filter by category, author, date range, and status.
- Pages: Filter by author, date range, and status.
- Media: Attachment records only, optionally filtered by date.
- Custom post types: Any exportable CPTs are listed by name.
- Click Download Export File: WordPress generates the XML file and your browser downloads it. The filename looks like
sitename.WordPress.2026-09-11.xml.
Store this file somewhere safe. If you're exporting a large site, consider exporting in smaller batches by date range or post type, which makes importing easier later.
How to Import Content Into WordPress
Before importing, make sure the destination site is ready. If it uses a different theme, install it first. If the content relies on custom post types or plugins (like WooCommerce products or ACF fields), install and activate those plugins first, so WordPress recognizes the content types.
- Take a backup: If the destination site already has content, back it up first. Imports can't be easily undone.
- Open the import screen: Go to Tools > Import.
- Install the WordPress importer: Find WordPress in the list and click Install Now. Once it's installed, click Run Importer.
- Upload the file: Click Choose File, select your XML export file, and click Upload file and import.
- Assign authors: For each author in the file, you can:
- Create a new user with the same login name.
- Assign their posts to an existing user on the new site.
- Import attachments: Tick Download and import file attachments. This tells WordPress to fetch the media files from the original site's URLs and add them to the new Media Library.
- Click Submit: The import runs. Depending on the size, this can take anywhere from a few seconds to several minutes.
- Check the results: When it finishes, you'll see "All done. Have fun!" along with any errors. Review your posts, pages, media, and menus.
Importing Media Files Successfully
The attachment option only works if the original site is still online and publicly accessible, because WordPress downloads each file from its old URL. If the old site is offline, behind a login, or blocking requests, media imports will fail.
In that case, you have a couple of options:
- Copy the
wp-content/uploadsfolder from the old site to the new site via FTP or your host's file manager, then use a plugin like Media Sync to register the files in the Media Library. - Use a full migration plugin that moves files along with the database.
Fixing Image URLs After Import
Imported posts may still point to images on the old domain. After importing, you can update URLs across the database with a search and replace. The WP-CLI method is covered below, or you can use a plugin like Better Search Replace. Always run a dry run first and back up before making changes.
How to Handle Large Export Files
The importer uploads the XML file through your browser, so it's limited by your server's maximum upload size. You can see the limit on the Tools > Import > WordPress screen, labeled as "Maximum size".
If your file is too large or the import times out:
- Split the export: Export posts by date range, or export posts, pages, and media separately.
- Split the file: Tools exist that split a WXR file into smaller valid files, though exporting in batches is simpler.
- Increase limits: Ask your host to raise
upload_max_filesize,post_max_size,max_execution_time, andmemory_limit. - Use WP-CLI: Command-line imports don't have browser upload limits or timeouts in the same way.
- Run the import again: The importer skips posts that already exist (matched by title and date), so re-running after a timeout usually continues where it left off without duplicating content.
Importing and Exporting With WP-CLI
WP-CLI is the fastest and most reliable option for developers and large sites.
Exporting With WP-CLI
# Export all content to the current directory
wp export
# Export only posts from a specific category, into a folder
wp export --post_type=post --category=news --dir=./exports
# Export content from a date range
wp export --start_date=2025-01-01 --end_date=2025-12-31
# Split exports into files of roughly 10 MB each
wp export --max_file_size=10
Importing With WP-CLI
First, make sure the WordPress importer plugin is installed:
wp plugin install wordpress-importer --activate
Then run the import:
# Import and create authors as needed
wp import ./exports/sitename.WordPress.2026-09-11.xml --authors=create
# Import and skip attachment downloads
wp import ./exports/sitename.WordPress.2026-09-11.xml --authors=skip --skip=attachment
The --authors option accepts create, mapping.csv, or skip. Using a mapping CSV lets you map old usernames to new ones precisely.
Search and Replace URLs
After moving content to a new domain, update old URLs:
# Preview changes first
wp search-replace 'https://old-site.com' 'https://new-site.com' --dry-run
# Apply the changes
wp search-replace 'https://old-site.com' 'https://new-site.com' --skip-columns=guid
WP-CLI's search-replace handles serialized data correctly, which is important, because a plain SQL find-and-replace can break serialized options and widgets. The guid column is skipped because it's an identifier that shouldn't change.
Importing From Other Platforms
The Tools > Import screen also offers importers for other platforms:
- Blogger
- LiveJournal
- Movable Type and TypePad
- Tumblr
- RSS (for importing posts from any RSS feed)
- Categories and Tags Converter (for converting between the two within WordPress)
Each importer is a separate plugin that you install from this screen. For platforms not listed, such as Medium, Squarespace, Wix, or Ghost, you'll usually need to export content from that platform first and then use a dedicated migration tool or plugin. Some platforms, like Squarespace, can export directly to the WordPress XML format.
Importing and Exporting With CSV Files
Sometimes you need to import structured data from a spreadsheet, such as product lists, directory entries, or event listings. The WordPress importer doesn't handle CSV files, but plugins do:
- WP All Import and WP All Export: Powerful tools for importing and exporting CSV and XML with custom fields, taxonomies, and images, including scheduled imports in the paid versions.
- WooCommerce's built-in product importer and exporter: Found under Products > All Products, with Import and Export buttons, for moving products via CSV.
For developers, a small WP-CLI command or script using wp_insert_post() is also a clean option. Here's a simple example that imports posts from a CSV file with title, content, and category columns. Save it as a file in your project and run it with wp eval-file:
<?php
// Usage: wp eval-file import-posts.php
if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
return;
}
$sajjad_csv_path = __DIR__ . '/posts.csv';
if ( ! file_exists( $sajjad_csv_path ) ) {
WP_CLI::error( 'CSV file not found.' );
}
$handle = fopen( $sajjad_csv_path, 'r' );
$header = fgetcsv( $handle );
$count = 0;
while ( ( $row = fgetcsv( $handle ) ) !== false ) {
$data = array_combine( $header, $row );
if ( empty( $data['title'] ) ) {
continue;
}
$category_ids = array();
if ( ! empty( $data['category'] ) ) {
$term = term_exists( $data['category'], 'category' );
if ( ! $term ) {
$term = wp_insert_term( sanitize_text_field( $data['category'] ), 'category' );
}
if ( ! is_wp_error( $term ) ) {
$category_ids[] = (int) $term['term_id'];
}
}
$post_id = wp_insert_post(
array(
'post_title' => sanitize_text_field( $data['title'] ),
'post_content' => wp_kses_post( $data['content'] ),
'post_status' => 'draft',
'post_type' => 'post',
'post_category' => $category_ids,
),
true
);
if ( is_wp_error( $post_id ) ) {
WP_CLI::warning( 'Failed: ' . $data['title'] . ' - ' . $post_id->get_error_message() );
continue;
}
$count++;
}
fclose( $handle );
WP_CLI::success( sprintf( 'Imported %d posts as drafts.', $count ) );
Posts are created as drafts so you can review them before publishing.
Exporting Content for Custom Post Types
If a custom post type doesn't appear on the Tools > Export screen, it was probably registered with can_export set to false. The default is true, so this is usually a deliberate choice by a plugin. If it's your own post type, check the register_post_type() arguments:
register_post_type(
'sajjad_portfolio',
array(
'public' => true,
'show_in_rest' => true,
'can_export' => true,
'label' => __( 'Projects', 'sajjad' ),
)
);
Remember that the destination site must also register the same post type before you import, or those items will be imported but hidden.
Exporting Templates and Styles From Block Themes
In block themes, customizations you make in the Site Editor are stored in the database. You can export them as a theme:
- Go to Appearance > Editor.
- Open the Options menu (three dots) at the top of the Site Editor.
- Choose Export.
This downloads a ZIP file of your theme including your template, template part, and style changes, which you can install on another site. For individual patterns, use Export as JSON from the pattern library.
Import and Export vs. Full Migration
It helps to be clear about which tool fits the job:
- Built-in import and export: Content only. Best for moving posts and pages to a site with a different setup.
- Migration plugins (such as All-in-One WP Migration, Duplicator, or Migrate Guru): Move the whole site, including the database, themes, plugins, uploads, and settings. Best for changing hosts or domains.
- Backup plugins (such as UpdraftPlus): Create restorable copies of your whole site. Best for disaster recovery.
If you're moving house, use a migration plugin. If you're only moving the furniture you care about, use export and import.
Troubleshooting Common Import Errors
"Sorry, there has been an error. The file is empty.": The file is larger than your upload limit, even though the message suggests otherwise. Split the file or increase the limit.
"Failed to import Media": The importer couldn't download attachments. Check that the old site is online and public, or move the uploads folder manually.
Import stops partway through: The server timed out. Run the import again (existing posts are skipped), split the file, or use WP-CLI.
"This does not appear to be a WXR file": The file is corrupted or isn't a WordPress export. Re-export it, and make sure you didn't open and save it in a program that altered the formatting.
Custom post types missing after import: Install and activate the plugin or code that registers them before importing.
Menus imported but not showing: In classic themes, go to Appearance > Menus and assign the menu to a theme location. In block themes, select the menu in the Navigation block.
Duplicate content: Running imports into a site that already has similar content can create duplicates if titles or dates differ slightly. Test imports on a staging site first.
FAQ: Importing and Exporting WordPress Content
No. The export file includes references to your media, not the files themselves. When importing, tick Download and import file attachments to fetch them from the original site, which must still be online.
No. An export only includes content like posts, pages, comments, and menus. A backup includes your full database, themes, plugins, and uploaded files.
Split the export into smaller files by date or post type, ask your host to raise upload and time limits, or use WP-CLI with the wp import command, which avoids browser upload limits.
No. The importer adds new content and skips posts that already exist with the same title and date. It doesn't delete or overwrite existing posts.
Yes. On the Tools > Export screen, choose Posts and filter by category, author, date range, or status. WP-CLI offers even more filters.
The core importer doesn't support CSV. Use a plugin like WP All Import, WooCommerce's product importer for products, or a custom script that uses wp_insert_post().
They may be registered with can_export set to false, or the plugin that registers them isn't active. Check the post type's registration settings.
Conclusion
WordPress's built-in import and export tools make it easy to move content between sites. Export from Tools > Export, import with the WordPress importer under Tools > Import, map your authors, and let WordPress fetch your media from the original site. For large sites, WP-CLI's wp export, wp import, and wp search-replace commands make the process faster and more dependable.
Just remember what these tools are for: content, not complete sites. Install required themes and plugins before importing, back up the destination site first, and test on staging when you can. When you need to move everything at once, reach for a migration plugin instead. With the right tool for the job, moving your WordPress content becomes a smooth, predictable task.


