Skip to content

Instantly share code, notes, and snippets.

@twentyfortysix
Last active January 18, 2024 22:58
Show Gist options
  • Save twentyfortysix/72c4609f16b0709e71e3652900b352d2 to your computer and use it in GitHub Desktop.
Save twentyfortysix/72c4609f16b0709e71e3652900b352d2 to your computer and use it in GitHub Desktop.
partial WP export-import
# Export each post individually
POST_IDS=$(wp post list --post_type=locations --meta_key=page_subtype --meta_value=event --format=ids)
for ID in $POST_IDS; do
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
wp export --dir=export --post__in=$ID
mv export/doprcenakole.wordpress.*.xml export/${TIMESTAMP}.xml
done
# Switch to the other WordPress installation
cd /path/to/other/wordpress/installation
# Import each XML file
for FILE in ../../dev.dopracenakole.cz/bedrock/export/*.xml; do
wp import $FILE --authors=create
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment