How to assign name the WordPress export.xml file

I maintain a bunch of different WordPress sites, and I have noticed a wide variety of default filenames for the XML cont

I maintain a bunch of different WordPress sites, and I have noticed a wide variety of default filenames for the XML content export file (Tools-Export-all content). Some of them even use a PHP extension for the downloaded XML file.

How can I set or define the name of the export.xml file? Thanks!

I maintain a bunch of different WordPress sites, and I have noticed a wide variety of default filenames for the XML content export file (Tools-Export-all content). Some of them even use a PHP extension for the downloaded XML file.

How can I set or define the name of the export.xml file? Thanks!

Share Improve this question asked Oct 13, 2019 at 18:30 user3827186user3827186 1
Add a comment  | 

1 Answer 1

Reset to default 1

By default, the filename is defined in /wp-admin/includes/export.php:

$sitename = sanitize_key( get_bloginfo( 'name' ) );
if ( ! empty( $sitename ) ) {
    $sitename .= '.';
}
$date        = gmdate( 'Y-m-d' );
$wp_filename = $sitename . 'WordPress.' . $date . '.xml';

And you can filter it:

$filename = apply_filters( 'export_wp_filename', $wp_filename, $sitename, $date );

So you could make a plugin and add a filter there:

add_filter(
    'export_wp_filename',
    function( $wp_filename, $sitename, $date )
    {
        // do something here, and then return a string
    }, 10, 3
);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745084347a4610313.html

相关推荐

  • How to assign name the WordPress export.xml file

    I maintain a bunch of different WordPress sites, and I have noticed a wide variety of default filenames for the XML cont

    12小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信