我建议退房WP-CLI 任何时候,您都需要在POST上执行批量操作,而无需通过传统界面进行访问。对于您的情况,您希望注册一个类似于以下示例的命令,该命令将遍历所有类型为“your\\u post\\u type”的帖子:
<?php if ( ! defined( \'WP_CLI\' ) ) return;
/**
* Basic structure for http://wordpress.stackexchange.com/q/161963/13937
*
* @package wp-cli
*/
class Wpse161963_Command extends WP_CLI_Command {
/**
* Clean posts
*
* ## OPTIONS
*
* ## EXAMPLES
*
* wp wpse161963 scrub
*
*/
public function scrub( $args, $assoc_args ) {
$args = array(
\'post_type\' => \'your_post_type\',
\'posts_per_page\' => -1
);
$posts = get_posts( $args );
foreach ( $posts as $post ) {
// Scrub the post content and save the results
// Print a success message
WP_CLI::success( sprintf( __( \'Post "%s" has been scrubbed!\', \'wpse161963\' ), $post->post_title );
}
}
}
WP_CLI::add_command( \'wpse161963\', \'Wpse161963_Command\' );
请注意,这只是一个示例,但它应该足以让您走上正确的道路。