Topic: Use Dropbox Files In Advanced Custom Fields
With the File Manager for Dropbox plugin, you can easily access your Dropbox files directly from the WordPress dashboard. This integration becomes even more powerful when combined with Advanced Custom Fields (ACF) — allowing you to attach Dropbox-hosted files (PDFs, videos, images, docs, etc.) to custom fields on your posts, pages, products, and more.
In this guide, you’ll learn how to:
- Connect your Dropbox account
- Create an ACF field for Dropbox files
- Display Dropbox files on the front-end in Custom coded theme
Prerequisites
- Make sure the ACF Integration is enabled from Settings > Integrations
- Advanced Custom Fields (ACF) plugin is installed and activated
- File Manager for Dropbox plugin installed and Dropbox account connected
Create a Custom Field in ACF
- Go to Custom Fields → Add New.
- Create a field group and assign it to your desired post type.
- Add a new field:
- Field Label: Dropbox File
- Field Name: dropbox_file
- Field Type: File
- Under Return Format, select either File URL or File Array depending on how you want to use it in your template.
- Publish the field group.
Add Files/photos from Post/Product/Page, etc
Go to the Edit posts or products, and add files from Dropbox Use Dropbox Files In Advanced Custom Fields
Display Dropbox Files on the Front-End
Depending on your return format, use the following code in your theme:
<?php $file_url = get_field('dropbox_file'); if ($file_url): ?> <a href="<?php echo esc_url($file_url); ?>" target="_blank" rel="noopener">Download File</a> <?php endif; ?>