---
title: "How to Copy Post Content HTML from WordPress with WP-CLI"
description: "Date: 11/8/19&nbsp;&nbsp;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..."
url: https://www.inmotionhosting.com/support/edu/wordpress/wp-cli/how-to-copy-post-content-html-from-wordpress-with-wp-cli/
date: 2019-11-21
modified: 2021-08-16
author: "Christopher Maiorana"
categories: ["WP-CLI"]
type: post
lang: en
---

# How to Copy Post Content HTML from WordPress with WP-CLI

Date: 11/8/19  2 Minutes To Read

[WP-CLI](https://www.inmotionhosting.com/support/edu/wordpress/wp-cli/wp-cli-search-replace-command/) is a command line tool that comes with your [WordPress Hosting](https://www.inmotionhosting.com/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](#code)
- [How to copy post content with WP-CLI](#copy-content)

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:

1. Log into your terminal
2. Navigate to the WordPress site directory (where the core files reside)
3. Get your post ID [using WP-CLI](https://www.inmotionhosting.com/support/edu/wordpress/wp-cli/how-to-find-post-details-using-wp-cli/) or previewing a URL from the post list in the dashboard (URL will contain `?post=###`)
4. 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](https://www.inmotionhosting.com/support/edu/wordpress/wp-cli/), the command-line interface for WordPress, and how to streamline your WordPress maintenance workflows!
