How to Trigger Cloning from Custom Code or Another Plugin

$array_of_post_types = array(








$array_of_tables = array(













* Set up the cloning request.

* These are the same fields that get submitted via an AJAX request when cloning via the

* admin interface, so you can inspect that request to determine other ways to configure

* the parameters, particularly if you're using NS Cloner Pro and want to use another

* clone mode (like clone-over or teleport / remote cloning)


$request = array(

'clone_mode' => 'core',

'source_id' => 1, // any blog/site id on network

'target_name' => 'subdomain-or-subdir',

'target_title' => 'New Site Title',

'tables_to_clone' => $array_of_tables,

'do_copy_posts' => 1,

'post_types_to_clone' => $array_of_post_types, // can customize post types . . .

'debug' => 1,

'clone_nonce' => wp_create_nonce( 'ns_cloner' ),


// Load WordPress (ONLY if invoking this from outside WordPress).

// Other plugins and themes do NOT need to do this.

require_once( 'wp-load.php' );

// This is required to bootstrap the required plugin classes.


foreach ( $request as $key => $value ) {

ns_cloner_request()->set( $key, $value );




// Run init to begin. This will run in the background


Still need help? Contact Us Contact Us