Using WP-CLI with Vagrant and creating a post


First off make a vagrant box with wordpress installed

Let’s now install WP-CLI

Now vagrant ssh into your vagrant box

First you are going to run this command

 

Check to make sure WP-CLI is installed type this in the terminal

 

You should get something that looks like this

 

To be able to type just wp, instead of php wp-cli.phar, you need to make the file executable and move it to somewhere in your PATH. For example

 

Next you need to cd into where your wordpress file is in your vagrant box
Cd  /var/www/html
 

Then type wp –info to test and made sure you moved it to the right spot. If you did it right you should get something like this

 

Now that we are cd into the folder where our WordPress is. We are now add 5 blogs to the post. Don’t get scared its really easy. We will walk through it together.
 


 

The “curl” part of the code is grabbing the api to give the post dummy text. then wp post generate is a WP-CLI command to generate the posts. the count is how many you want. For this demo we are only doing 5. You can change that to 100 if you want.  then you have –post_content. This publishes the content right away.
 

Now you ask how would i add 5 post to my custom post type.  I gotcha boo. Lets walk through that right now.
 

Its just like wp post generate, but your just adding –post_type=”your post type” right after wp post generate. Here is the code and example what it should look like.

February 2, 2017 10:46 pm Published by