How to Copy Post Content HTML from WordPress with WP-CLI Updated on August 16, 2021 by Christopher Maiorana 1 Minutes, 39 Seconds to Read Date: 11/8/19 2 Minutes To Read WP-CLI is a command line tool that comes with your WordPress Hosting package. You can use it to manage your WordPress site with quick and intuitive command line instructions. Utilized properly, WP-CLI can drastically speed up your workflow and replace tedious dashboard operations with efficient scripts you can repeat and automate. Copy post content code snippet How to copy post content with WP-CLI Using the new Gutenberg editor lets you place content into convenient blocks. But what happens if you need to copy the content of a long int HTML? You would need to preview each Gutenberg block separately as HTML, copy, and paste it into a local HTML file. For a long post, this is incredibly time-consuming and will introduce multiple opportunities for error. Using WP-CLI can ensure you copy the HTML content perfectly and preserve it in an HTML file. Copy Post Content from WordPress With WP-CLI One-liner WP-CLI provides an easy shortcut for accessing specific database tables where your content. Using the command below you can have WP-CLI go into the database, get post content, and output that content to a file: Send content to a file in the same directory: $ wp post get 123 --field=content > file.html Second content to a file in your home directory by adding a tilde ~: $ wp post get 123 --field=content > ~/file.html How to Copy Post Content to a File with WP-CLI Here are the steps on how to use the above commands and where they need to go: Log into your terminal Navigate to the WordPress site directory (where the core files reside) Get your post ID using WP-CLI or previewing a URL from the post list in the dashboard (URL will contain ?post=###) Use one of the above code snippets with the post ID number When you visit your file, you will notice that it is filled with HTML content you can save or paste into WordPress as needed. Learn more about WP-CLI, the command-line interface for WordPress, and how to streamline your WordPress maintenance workflows! Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles Install and Configure WP-CLI How to Create and Delete a WordPress Page Using WP-CLI Install a Theme Using WP-CLI Install WordPress Using WP-CLI Manage WordPress Comments Using WP-CLI Update WordPress Using WP-CLI Manage WordPress Users Using WP-CLI WP-CLI search-replace Command Delete WordPress Transients Using WP-CLI Manage WordPress Plugins with WP-CLI