How to View Page Content Using WP-CLI

InMotion Hosting’s WordPress Hosting includes WP-CLI. This intuitive tool allows you to maintain your WordPress websites’ content directly from the command line, as an alternative to using the Administrative Dashboard. In this guide, you will learn how to display the content of a Page, from the Command Line, using the wp post get command, in WP-CLI.

View Page Content

First you will need to find the ID of the Page. You can use the ID to identify and manipulate each Page in WP-CLI. Once you find the Page ID

, you can use the wp post get subcommand to find the content of a particular Page. To view the content of a page, simply follow the steps below.

  1. SSH into your server as the cPanel user that owns the website you would like to work with.

  2. Use the cd command to switch to the document root directory of your website.

    Example: cd public_html/wp

  3. Run the following command:

    wp post get ## –field=post_content

  4. The output will be similar to the example below:

    exampl3@example.com [~/public_html/wp]# wp post get 42 --field=post_content <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-6 col-xs-12 col-sm-12"> <h2 class="">The Write Stuff</h2> <h4 class="">A Better Copywriting Service</h4> <div class="row gridblock"> <div class="col-md-12 col-xs-12 col-sm-12">  <hr></div> </div> </div> <div class="col-md-6 col-sm-12 col-xs-12">     </div> </div> </div> </div> <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-6 col-margin-bottom col-xs-12 col-sm-12">  The concept for my company was a team effort. After chatting with local copywriters at a marketing expo, founder Janet Riley wanted to create a business where marketers and copywriters could work together to create a message that clients could genuinely get behind while driving sales for that client. Tired of the continuous process of finding clients, wooing them into hiring her for projects and then having to start over again once the project was complete, she dreamed of a better way.

    Teaming up with several copywriters in the area, she formed The Write Stuff, a copywriting service that paired copywriters with the companies that needed their unique offerings. Over the past decade, The Write Stuff covers social media and blog content, white papers, copywriting and so much more! <p class="p-button-primary"><a class="button-primary" href="#">View Our Services</a> <a class="button-secondary" href="#">Visit Our Gallery</a></p>  </div> <div class="col-md-6 col-margin-bottom text-center col-xs-12 col-sm-12"> <p class="mod-img"><img class="wp-image-91 wp-image-59" src="https://www.example.com/wp/wp-content/uploads/2018/02/aHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL2dwOEJMeWFUYUEwLzYwMHgzMDA_3D-imhwpb-3hx4cj8bmyayisq.jpg" alt="" data-imhwpb-asset-id="780828"></p>  </div> </div> </div> </div> <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-12 col-xs-12 col-sm-12"> <div class="mod-space"></div> <div class="mod-space"></div> <div class="mod-space"></div> <div class="mod-space"></div> </div> </div> </div> </div> <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-3 col-sm-12 col-xs-12">     </div> <div class="col-md-9 col-xs-12 col-sm-12"> <h2 class="">Janet Riley</h2> <h4 class="">MBA</h4> <div class="row gridblock"> <div class="col-md-12 col-xs-12 col-sm-12">  <hr></div> </div> </div> </div> </div> </div> <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-3 col-margin-bottom text-center col-xs-12 col-sm-12"> <p class="mod-img"><img class="alignnone size-full wp-image-60" src="https://www.example.com/wp/wp-content/uploads/2018/02/aHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL1dIV1lCbXRuM18wLzYwMHg0NTA_3D-imhwpb-3jdbnyuh81bfd64.jpg" alt="" data-imhwpb-asset-id="780829" width="600" height="450"></p>  </div> <div class="col-md-5 col-margin-bottom col-xs-12 col-sm-12">  With a fabulous talent for writing seductive copy, a natural eye towards business matters and drive to succeed, founder Janet Riley had over 20 years' in the copywriting business before forming The Write Stuff. She'd discovered over the years that the never-ending process of "find project", "finish project", "repeat", was getting old. She wanted to focus on the writing end of her business, not spend all her time seeking clients.  With an MBA, serious copywriting chops and a fabulous sense of humor that comes across in her writing, Janet has undertaken copywriting for such corporate giants as Hewlett Packard, Barnes & Noble, Macy's and numerous Fortune 500 companies. <p class="p-button-primary"><a class="button-primary" href="#">See Janet's Resume</a></p>  </div> <div class="col-md-4 col-sm-12 col-xs-12"> <p class="mod-img-circle"><img class="alignnone size-full wp-image-61" src="https://www.example.com/wp/wp-content/uploads/2018/02/aHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL0lPems4WUtEaFlnLzMwMHgzMDA_3D-imhwpb-ijgqofoxxyngmlu.jpg" alt="" data-imhwpb-asset-id="780830" width="300" height="300"></p>  <div class="row gridblock"> <div class="col-md-6 col-xs-12 col-sm-12"> <div class="mod-space"></div> </div> </div> <div class="mod-blockquote">  "serious copywriting chops and a fabulous sense of humor"  </div> </div> </div> </div> </div> <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-12 col-xs-12 col-sm-12"> <div class="mod-space"></div> <div class="mod-space"></div> <div class="mod-space"></div> <div class="mod-space"></div> </div> </div> </div> </div> <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-6 col-xs-12 col-sm-12"> <h2 class="">The Crew</h2> <h4 class="">A Team You Can Rely On</h4> <div class="row gridblock"> <div class="col-md-12 col-xs-12 col-sm-12">  <hr></div> </div> </div> <div class="col-md-6 col-sm-12 col-xs-12">     </div> </div> </div> </div> <div class="boldgrid-section"> <div class="container"> <div class="row gridblock"> <div class="col-md-6 col-margin-bottom col-xs-12 col-sm-12">  Janet knows she wouldn't get a fraction of the things done she wants to if it wasn't for her awesome crew. Kara Margules heads up our sales department, helping us find new clients in need of copywriting services when she's not hitting the sales herself. Marie St. Clair keeps our copywriters working while developing awesome new craft designs. Jason Andrews leads our exceptional IT support team when he's not making a new batch of award-winning homebrewed ale.  The Write Stuff wouldn't be anywhere if it wasn't for our highly-skilled team of copywriters. Covering industries from accounting to zoo advertising, our amazing copywriters can cover any campaign for any business anywhere in the world. <div class="row gridblock"> <div class="col-md-4 col-xs-12 col-sm-12"> <p class="mod-img-circle"><img src="https://www.example.com/wp/wp-content/uploads/2018/02/1-3047411040_c570e17b0a_m-200x200.jpg" alt="" data-imhwpb-built-photo-search="130|square" width="200" class="wp-image-62"></p>  </div> <div class="col-md-4 col-sm-12 col-xs-12"> <p class="mod-img-circle"><img src="https://www.example.com/wp/wp-content/uploads/2018/02/6-C_1jjFJioWg-200x200.jpg" alt="" data-imhwpb-built-photo-search="8|square" width="200" class="wp-image-63"></p>  </div> <div class="col-md-4 col-sm-12 col-xs-12"> <p class="mod-img-circle"><img src="https://www.example.com/wp/wp-content/uploads/2018/02/1-5368014945_f5b4f8313f_z-200x200.jpg" alt="" data-imhwpb-built-photo-search="8|square" width="200" class="wp-image-64"></p>  </div> </div> </div> <div class="col-md-6 col-margin-bottom text-center col-xs-12 col-sm-12"> <p class="mod-img"><img class="wp-image-94 wp-image-65" src="https://www.example.com/wp/wp-content/uploads/2018/02/aHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL0Jja1BhVHYxUlo4LzYwMHgzMDA_3D-imhwpb-8yn1htn2n7bbs9c.jpg" alt="" data-imhwpb-asset-id="780831"></p>  </div> </div> </div> </div> 		

Now that you are familiar with a Page ID, you can use that ID to view the Page content. To learn more about maintaining Pages from the command line, be sure to check out our guide to learn How to Create and Delete a WordPress Page Using WP-CLI.

Leave a Reply