Questions

Forum Navigation
Please to create posts and topics.

Allow to upload XML files in WordPress

How to enable in Wordpress the upload of .xml files? I need that as I'm publishing some on my website...

For security reasons, WordPress does not allow to upload XML files into the media library, by default.

To alleviate this limitation, you have to add the following PHP code to functions.php in your current theme.

add_filter('upload_mimes', 'custom_upload_xml');
function custom_upload_xml($mimes) {
$mimes = array_merge($mimes, array('xml' => 'text/xml'));
return $mimes;
}


The path to this file is [WORDPRESS_ROOT]/wp-content/themes/[MY_THEME]/functions.php.