If you run a file download site or want to create a custom post type that requires you to add a download link on each post, then you need to use a dynamic download link for the file. With a dynamic download link, you can add a distinct link on each post with the same layout.
The dynamic link is created by filling a custom field with a link, and the custom field itself is created with the help of a custom field plugin like ACF (Advanced Custom Field) or Pods. Then by using Divi Theme Builder, you create a custom template to pull the link to the download button (or text) with the dynamic content function.
Here is the gist of the steps that you’ll follow in the tutorial:
- Create a custom field to place the dynamic download link
- Create a custom template for the posts with a download button to pull the download link from the custom field
- Create a post using the template you created and place the link in the download link custom field
Step 1: Create the Dynamic Download Link Custom Field
To get started, you need to install and activate the ACF plugin first since we use it for this tutorial. You can get the plugin for free from wordpress.org. Or you can skip this step if you are using another plugin (read: ACF alternatives).
Once you’re ready, go to Custom Fields → Add New from the WordPress dashboard. On this page, you will create a field group for the custom field. Start by giving the group a title then proceed to add the field to this group by clicking the +Add Field button.
Continue by filling out all the necessary fields. Then set the Field Type section to URL so the field can be used to place your download link later.
You can add more custom fields by clicking on the +Add FIeld button.
Since we just need one custom field for the download link, let’s continue our tutorial by moving to the Location block to set the rules for the custom field location to appear. Here you can choose where to add your custom field. From the page, post, and if you have created a custom post type for it, you also can select it from this block also. This time we will use the regular post (blog post) by setting the rules as follow:
- Post type → Is Equal to → Post
You can leave the Settings block to its default, and once you’re ready, save your custom field by clicking the Publish button.
Step 2: Create a Custom Template in Divi Theme Builder
After you created the custom field to place the download link, the next step is to create a custom template for the blog post since the custom field is assigned to it.
The custom template’s purpose is to pull the link from the blog post by using the Divi dynamic content functionality.
Start by going Divi → Theme Builder from your WordPress dashboard. On this page, start to create a new template by clicking on the + Add New Template button.
On the new appearing window, select the Post → All Post option then continue by clicking on the Create Template button.
Once clicked, you still need to select which part of the post you want to create the template for. Since we need to create a post content with the dynamic download link, then click on the Add Custom Body block, and you will be offered to use the premade layout by clicking Add From Library or if you want to build the template from scratch, simply click Build Custom Body option.
Once you clicked the button, you will be taken to the Divi Builder editor to create your template. Feel free to add all the modules you need to the editor. Once you are ready, add the button module for the download button. You can customize the button style in the Design tab, and the button position in the Advanced tab.
After you finished the button design, then proceed to add the dynamic download link for the button.
As we said before, the link in the button will be the link from the URL you’ll place in the custom field on the blog post later. To make it so, go back to the Content tab of the Button Settings then move to the Link block, then hover a bit on the right side of the Button Link URL field to display the database icon and click it to show the dynamic content option. Proceed to select the dynamic download link custom field you created from the list.
Once you did the step above, proceed to save your changes to the button, and your button will be ready for the dynamic download link!
Remember to save your template to proceed to the next step.
Step 3: Create a New Post
It’s time to create a new post! And make sure you create the post type according to the template and custom field you’ve created for the dynamic download link.
As we use the blog post type for this tutorial, then add a title, a featured image, the content, and another blog-related thing as usual, then proceed to place the download link in the dynamic download link custom field on the custom field section below the editor.
Publish the post once the post is ready.
The Bottom Line
Introduced in 2018, dynamic content in Divi allows you to build dynamic posts that automatically update themselves as the content changes. If combined with the custom field and the custom post type you’ll have some of the main keys to unlock WordPress power to build custom dynamic WordPress sites.
A dynamic download link is just one of the implementations of dynamic content in Divi, which will be very useful if you run a file download website or stock photo website.