PHP code example of wp-cli / entity-command

1. Go to this page and download the library: Download wp-cli/entity-command library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wp-cli / entity-command example snippets


WP_CLI::add_hook( 'after_invoke:site empty', function(){
    global $wpdb;
    foreach( array( 'p2p', 'p2pmeta' ) as $table ) {
        $table = $wpdb->$table;
        $wpdb->query( "TRUNCATE $table" );
    }
});