Add a vCard to Your WordPress Site

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;
}

Lena Shore

2 Comments

  1. Rachel D. Graham on September 1, 2015 at 11:52 pm

    I just added the above suggested code to my page and the entire page disappeared. Please help. Several days worth of work have been lost.



    • Lena Shore on September 2, 2015 at 6:59 am

      Rachel – I wouldn’t worry much about your code/work being gone. This can happen if you miss a character. Once that is corrected, I imagine your code will all come back.

      Depending upon how your functions file is laid out you may or may not need a closing php tag. Look at that first. You are welcome to send me your functions file (my contact form has an upload area) and I’ll take a look at it.

      (:



Archives