Categories
Code WordPress

WP CLI Batch Import

Sometimes you may receive your WordPress export XML files broken up into chunks.  When this happens, it can be cumbersome to import each file one-by-one.  Instead, try throwing everything into a sub-folder and running the following shell script:

# Activate the wordpress importer
wp plugin activate wordpress-importer --url=http://localhost/example.com/
# Iterate over all of the import files in a given folder.
for f in myfolder/*.xml; do wp import $f --authors=skip --skip=attachment --url=localhost/example.com/; done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.