Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Empty Posts 2 Posts tables when using wp site empty
* Requires WP-CLI v0.24.0-alpha or later because it needs
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_hook( 'after_invoke:site empty', function(){
global $wpdb;
foreach( array( 'p2p', 'p2pmeta' ) as $table ) {
$table = $wpdb->$table;
$wpdb->query( "TRUNCATE $table" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment