How to Add Dynamic URLs to Your CTAs with Divi & ACF

How to Add Dynamic URLs to Your CTAs with Divi & ACF

When creating your website structure, chances are high that you’ll want to include the same CTAs on multiple pages, posts and projects. Of course, you can keep the URLs close by and copy-paste them as you go, but that isn’t necessarily the easiest way to go. Before you start creating your pages, posts and projects, you can set up a list of all the URLs you might need, set a default value for them and use the default values on new items you create.

If for any reason the URLs differ on a certain page, post or project, you can change that within the item itself without it applying to the entire field default value. The default values attached to URLs will help give you a headstart when creating a new page, post or project. In this tutorial, we’ll show you step-by-step how to get there!

Let’s get to it!

Tutorial Overview

  • This approach works best if you add the custom fields group to a new website, right before you start adding pages, posts and projects
  • Install the Advanced Custom Fields plugin on your WordPress website
  • Inside the plugin, you’ll be able to set up a fields group that’ll appear on all your pages, posts and projects
  • Create a separate URL field for all the possible URLs you might need throughout your website
  • Assign a default value to each one of the fields; this default value will automatically appear on each new page, post or project
  • On existing pages, posts and projects, the values will only appear once you enter the backend and save the default URLs
  • Use the URL fields throughout your Divi design as dynamic link content (page, post, project, template)
  • If you change the default URL in the field settings, the old default URL will still apply on pages, posts and projects that inherited the previous default value

1. Install & Activate the ACF Plugin

The first thing you’ll need to do is install the Advanced Custom Fields plugin on your website. You can download the plugin here, or just search for it inside your WordPress dashboard. After you’ve installed the plugin, make sure you activate it as well so you can get started right away.

2. Set up a Fields Group on All Posts, Pages & Projects

Now, once the ACF plugin has been installed, it’s time to create the URL fields group. This group will contain all the CTAs that you’ll use multiple times across your pages, posts and projects. Go to your WordPress Dashboard > Custom Fields > Add New.

dynamic urls

[…]

 



This article was written by Donjete Vuniqi and originally published on Elegant Themes Blog.

Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the product, We may receive an affiliate commission.

Leave a Comment

You have to agree to the comment policy.

Scroll to Top