PHP code example of soderlind / multisite-exporter

1. Go to this page and download the library: Download soderlind/multisite-exporter 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/ */

    

soderlind / multisite-exporter example snippets


/**
 * Change the directory where Multisite Exporter stores exported files
 */
add_filter( 'multisite_exporter_directory', 'my_custom_export_directory' );
function my_custom_export_directory( $default_export_dir ) {
    // Define a custom location for your export files
    return WP_CONTENT_DIR . '/my-custom-exports';
}

if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
    error_log( 'Multisite Exporter: [error message]' );
}

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

wp multisite-exporter export --site_ids=1,2,3

wp multisite-exporter export --start_date=2023-01-01 --end_date=2023-12-31

wp multisite-exporter export --site_ids=1,2,3 --content=posts,pages --start_date=2023-01-01