Example of creating a link using custom fields


I know this sounds stupid but I can’t work out how to create a heading with the text and the URL value coming from advanced custom fields values. I can get the dynamic data for the text from the post meta data but how do I set the URL to be from another ACF value?

I’ve hunted high and low and can’t find an example of how to do this. Can someone show me, please?


Is this possible to use ACF to create a link?

I have ACF and Generateblocks all setup and I want to create a link with the text and the URL coming from separate custom fields for example

field 1 (text) “https://instagram.com/test”
field 2 (text) “Text’s Instagram”

In GenerateBlocks I can use the dynamic data to set the heading objects text value to field 2. But when I go to make it a link (click the link) how do I use field 1’s value?

what I’m hoping for in HTML is: <a href='https://instagram.com/test'>Text’s Instagram</a>

ACF and GeneratePress & GenerateBlocks are commonly used together so I hope this is possible

Thanks in advance!

You can do this with either a Button block or a Headline block using the latest versions.

I have uploaded screenshots of 2 different methods you could use. Here I have used project_website_label as the text and project_website_link as the URL.

  1. Using the Dynamic Data options in the sidebar:

  2. Using the Dynamic Data icon in the toolbar:

Note that if you need the link to open in a new window, this is currently only possible if you use a Button block.

P.S. You might want to change your ACF Field 1 to a URL field, so only URLs can be entered as a value.

P.P.S. You will not see the content in the admin. You need to save your changes and check the frontend.

Thanks for the reply @jessefisher

When I follow your instructions and pictures above I have this issue:

The Post meta field isn’t in the dropdown list for me to select and what I enter “instagram” which is the field id it doesn’t allow it

Any ideas?

This is the fields in the field group

and as an example here is the populated fields for a post that is published

Sorry it would only allow me to paste 1 image - so I have to do 3 separate posts! :slight_smile:

Does anyone have any ideas - it’s driving me mad :angry: as I think it’s going to be something simple I’m doing wrong

You’ll need to change up how you are adding the fields.

For your instagram-url field, ACF saves the prepend and field value as 2 different parts and GenerateBlocks can only get 1 of them (the value).

I would change that field to a URL field so the full URL has to be entered. Note that while a Text field will also work for URLs that could lead to someone adding text that is not a URL and then the link won’t work.

When adding the post meta field, when you type in instagram you need to specifically click on the Add “instagram” notice or press the Enter key to lock it in.