
How to Upload File Type VCF in WordPress
- November 3, 2015
- Leave a comment
WordPress allows a list of specific file types/extensions to upload in WordPress media. File type .vcf is not from one of the default types supported by WordPress. You have to add some code in your theme’s functions.php file to upload the vcf file from media.
For this, WordPress provides its own filter. You can use it in your theme’s funcitons.php file and then try to upload the file having extension .vcf. It will work for you by adding the following code:
1 2 3 4 5 6 |
add_filter('upload_mimes', ‘pt_custom_upload_mimes'); function pt_custom_upload_mimes ( $existing_mimes=array() ) { // add your extension to the array $existing_mimes['vcf'] = 'text/x-vcard'; return $existing_mimes; } |
After this, you can also add the extension of such a file which is not included in WordPress default file extensions. For this, you simply have to change the extension from the array vcf to another extension as follows:
1 |
$existing_mimes['vcf'] = 'text/x-vcard'; |
The above not working.
Vcf files are not loaded for security reasons – WP 5.4 .
This post is 5 years old, lots has changed. This works as of Sep 2020…
/**
* Enable vCard
*/
function vcard_upload( $mime_types ){
$mime_types[‘vcf’] = ‘text/vcard’;
return $mime_types;
}
add_filter(‘upload_mimes’, ‘vcard_upload’ );
Hi, I added this code above within the function.PHP but it doesn’t work. Is this theme related or why do I not get this to work? After implementing the code and saving it, do I have to do anything else? I work with the astra, astra child theme.