vCard is a file format that stores contact information, such as name, phone number, email address, and website. It is commonly used to share contacts between devices and applications, such as email clients, smartphones, and social networks. vCard files usually have the extension .vcf or .vcard.
If you want to upload vCard files to your WordPress site, you may encounter some challenges. WordPress does not support vCard files by default, and you may get an error message saying “Sorry, this file type is not permitted for security reasons.” This is because WordPress only allows certain file types to be uploaded, such as images, documents, audio, and video.
Please note that allowing vCard files can have security implications, as they may contain executable code. Make sure to consider the security risks and use additional security measures if necessary.
However, there are ways to overcome this limitation and upload vCard files to WordPress. In this article, we will show you two methods to do that:
Method | Pros | Cons |
---|---|---|
Method 1: Using a plugin | Easy to install and use, no coding required, can upload multiple vCard files at once. | Requires an extra plugin, may not be compatible with some themes or plugins, may affect site performance or security |
Method 2: Using a code snippet | No extra plugin required, more control over the code, can customize the code to suit your needs | Requires some coding skills, may cause errors or conflicts if not done correctly, can only upload one vCard file at a time, cannot display vCard files on your site without additional code |
One of the easiest ways to upload vCard files to WordPress is to use a plugin that adds vCard support to WordPress. There are several plugins that can do this, but we will use one called Enable virtual card upload – vcf,vcard for this tutorial. WP vCard is a free plugin that allows you to upload and manage vCard files on your WordPress site.
To use of plugin, follow these steps:
Go to your WordPress dashboard and navigate to Plugins > Add New. Search for Enable virtual card upload – vcf,vcard and click on Install Now. After the installation is complete, click on Activate.
Go to Media Library > Add New. You will see a screen where you can upload vCard files to WordPress. You can upload multiple vCard files at once by selecting them from your computer or dragging and dropping them to the upload area. You can also add a title and a description for each vCard file.
After uploading the vCard files, click on Publish.
Another way to upload vCard files to WordPress is to use a code snippet that adds vCard support to WordPress. This method does not require any plugin, but it requires some coding skills and access to your WordPress files. You also need to be careful when editing your WordPress files, as any mistake can cause errors or conflicts on your site.
To use this method, follow these steps:
To add this code snippet to your WordPress site, you need to edit your functions.php file. This file is located in your theme folder, which you can access via FTP or your hosting control panel.
// Allow vCard (.vcf .vcard) file uploads
function allow_vcard_upload($mime_types){
$mime_types['vcf'] = 'text/vcard';
$mime_types['vcard'] = 'text/vcard';
return $mime_types;
}
add_filter('upload_mimes', 'allow_vcard_upload');
To edit your functions.php file, go to Appearance > Theme Editor. Select your active theme and find the functions.php file in the right sidebar. Scroll to the end of the file and paste the code snippet above. Click on Update File to save the changes.
You can also use a plugin like FluentSnippets to add code snippets to your WordPress site without editing any files.
Where to Run? can be chosen so the code runs only in the admin area, you need to let WordPress know that you are allowing these files.
After adding the code snippet, you can upload vCard files to WordPress using the Media > Add New option. You can only upload one vCard file at a time using this method. You can also add a title and a caption for the vCard file.
After uploading the vCard file, you will see it in your media library.
For Gutenberg you just go and add the file to the post or use the below with the code block:
Unlike the plugin method, this method does not provide a shortcode to display vCard files on your site. You will need to use the URL of the vCard file and create a link or a button for your visitors to download or import it.
To get the URL of the vCard file, go to Media > Library and click on the vCard file. You will see the URL in the File URL field. Copy the URL and use it to create a link or a button on your site.
For example, you can use HTML code to create a link like this:
<a href="https://example.com/wp-content/uploads/2023/12/contact.vcf">Download vCard</a>
or a button like this:
<button onclick="window.location.href='https://example.com/wp-content/uploads/2023/12/contact.vcf'">Download vCard</button>
You can use the HTML code in any post, page, or widget where you want to display the vCard file. When your visitors click on the link or the button, they can download or import the vCard file to their devices or applications.
Uploading vCard files to WordPress can be a useful way to share your contact information with your visitors and let them import it to their devices or applications. Just be careful when you enable this.