Using WordPress ‘export_args’ PHP filter

The export_args WordPress PHP filter allows you to modify the arguments passed to the WordPress exporter.

Usage

add_filter('export_args', 'my_custom_export_args');
function my_custom_export_args($args) {
    // your custom code here
    return $args;
}
// Output: Modified export arguments

Parameters

  • $args (array) – The array of arguments sent to the WordPress exporter.

More information

See WordPress Developer Resources: export_args

Examples

Modify export author

Change the author of the exported content:

add_filter('export_args', 'change_export_author');
function change_export_author($args) {
    $args['author'] = 2; // Set author ID to 2
    return $args;
}
// Output: Exported content with the modified author

Change export start date

Set a custom start date for the exported content:

add_filter('export_args', 'change_export_start_date');
function change_export_start_date($args) {
    $args['start_date'] = '2023-01-01'; // Set start date
    return $args;
}
// Output: Exported content starting from the specified date

Modify export end date

Set a custom end date for the exported content:

add_filter('export_args', 'change_export_end_date');
function change_export_end_date($args) {
    $args['end_date'] = '2023-04-01'; // Set end date
    return $args;
}
// Output: Exported content ending on the specified date

Change export post type

Modify the post type of the exported content:

add_filter('export_args', 'change_export_post_type');
function change_export_post_type($args) {
    $args['content'] = 'page'; // Set content to 'page'
    return $args;
}
// Output: Exported content with the specified post type

Change export status

Change the export status of the content:

add_filter('export_args', 'change_export_status');
function change_export_status($args) {
    $args['status'] = 'draft'; // Set status to 'draft'
    return $args;
}
// Output: Exported content with the specified status