brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp export writes a WordPress content export from the terminal

WordPress
~/tips/tip-wordpress-export-wxr-post-type

wp export --post_type=page --dir=exports

Creates the same WXR file as Tools > Export, filtered by post type or date.

Tools > Export in the dashboard gives you one XML file with everything. wp export makes the same WXR format, but you choose what goes in.

Only the pages, into a folder of their own:

mkdir -p exports
wp export --post_type=page --dir=exports

You can narrow it further. --start_date and --end_date take dates like 2025-01-01, --author takes a login or user ID, and --post__in=12,34,56 exports exactly those posts. --skip_comments leaves comments out, which I find useful when you only want to move content to a test site.

Big sites get split into several files, 15 MB each by default. Change that with --max_file_size, or set it to -1 for one file of any size. To pipe the XML somewhere else, use --stdout instead of --dir.

Keep in mind what WXR is: posts, pages, terms, comments and authors, not a backup. Settings, plugin tables, users’ passwords and the media files themselves are not in it. Attachments are listed with their URLs, and the importer downloads them from the old site later. For a real backup, dump the database and copy wp-content/uploads.

Further reading: wp export

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link