有几种方法。如上所述,post generate
.
wp post generate --count=10 --post_type=page --post_date=1999-01-04
curl http://loripsum.net/api/5 | wp post generate --post_content --count=10
你可以自己写
custom command. 请参见
List of community commands 例如
package index.
<?php
/**
* Implements example command.
*/
class Example_Command extends WP_CLI_Command {
/**
* Prints a greeting.
*
* ## OPTIONS
*
* <name>
* : The name of the person to greet.
*
* ## EXAMPLES
*
* wp example hello Newman
*
* @synopsis <name>
*/
function hello( $args, $assoc_args ) {
list( $name ) = $args;
// Print a success message
WP_CLI::success( "Hello, $name!" );
}
}
WP_CLI::add_command( \'example\', \'Example_Command\' );
以及
WPTest.io 是使用
import
命令从xml创建测试内容。
#!/bin/sh
#
# WP Test - WP-CLI Quick Install Script
# http://wptest.io/
#
# Note: This script assumes you have wp-cli installed.
#####################################################################################
# Ask user where WordPress is installed.
printf "Please provide the local path to your WordPress install: "
read WPPATH
# Import WP Test data.
cd $WPPATH
curl -OL https://raw.githubusercontent.com/manovotny/wptest/master/wptest.xml
wp import wptest.xml --authors=create
rm wptest.xml