How to export WordPress website content using WP CLI command line?

Click to read the original text

A few days ago, we needed to export a backup of a website with hundreds of articles and import it to another website. This website is on a virtual machine, but the proxy server no longer points the website domain name to this server, so this server cannot be accessed from the browser. Later, I thought of exporting the content using the WP CLI command line. Through Google and search WP CLI command line documentation , I found that it is feasible. You can use the wp export command to export articles and other content, and the wp import command to import it to another website. And export and import command line is still very powerful, it is a good tool for content backup and transfer.

For example command

wp export --dir=/tmp/ --user=admin --post_type=post --start_date=2020-01-01 --end_date=2020-12-31

Export the articles of the admin user between 2020-01-01 and 2020-12-31, where post_type can specify other custom content types, such as product, portofolio, etc.

And the command

wp import example.wordpress.2020-06-21.xml --authors=create

Import the xml file exported by wp export.

And the import command wp import is also very powerful. It can import categories, tags, and image files that do not exist in the new website. This information should exist in the export file.

In addition, the WP CLI command line function is not a plug-in and needs to be installed separately. For details, see the relevant documentation.

 

Guess you like

Origin blog.csdn.net/lilihuigz/article/details/112789510