Add a vCard to Your WordPress Site

vc-ard

January 21, 2014 / Updated: December 5, 2019 / Lena Shore
Filed under: ,

vc-ardAdding a vCard to your WordPress site may seem like an easy task. Unfortunately, when you try to add it as media, it is all too easy to get an error similar to: “Error saving media attachment.”

This is typically because WordPress doesn’t support that file type by default. “But WHY?” you might scream. “It’s a security feature!” a tight-fisted WordPress might answer. The makers of WordPress know not to give access to things you don’t need to – lest you open yourself up for hackers.

However, there may come a day where you need to add this functionality to your site. Happily, adding it is easy. Just pop this code into your functions file. After that you should be able to upload vCards through the Media area.

add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ){
// add your extension to the array
$existing_mimes['vcf'] = 'text/x-vcard'; return $existing_mimes;
}

NOTE: Your functions.php file is inside your theme folder on your server (wp-content –> themes –> yourtheme). However, you can often access it through Appearance –> Theme Editor from the admin area of your WordPress site.

Archives

Categories