Custom post type with ACF custom fields

Posted in: Newspaper
Post count: 72

Hi,
We’ve built a custom module which uses a custom post type with ACF custom fields. In those customs fields, we have an URL field we would like to use in a button. What can I do to automate the link in our custom button? Is there a shortcode we can put inside the URL so it can be replaced by our custom field value?

As shown on this screenshot, I tried to put the acf official shortcode inside but it is not interpreted :
https://devenirbilingue.com/wp-content/uploads/2024/12/screenshot-sandbox-2.png

Could you please help us to find a solution?
Thank you.
Emma

Post count: 27744

Hello Emma,

To set a URL on the button, use the element button and set the custom field there -> https://i.imgur.com/ZGYBjfE.png. You need to use {cf_nameoffield} -> https://i.imgur.com/F2ysuLA.png

Thank you!

Post count: 72

Hello Anamaria, I did as you said but it doesn’t work :
The URL of my button is now {cf_deal_url} and the custom field is set as a URL named deal_url
However, when I click on the related button of the custom module, it goes to https://devenirbilingue.com/%7Bcf_deal_url%7D (=> error page – the page doesn’t exist) instead of the URL set for that offer.
Would you be able to help ?
Many thanks.

Post count: 21065

Hello!

Are you sure that the name field is correct? Also, does the CPT have a value in Gutenberg added?

Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.