Support

Account

Home Forums Front-end Issues Using ACF shortcode inside html tag

Helping

Using ACF shortcode inside html tag

  • Hello,
    I am trying to display a URL on the front end, I would like the same URL to appear on the front end as both anchor text and hyperlink.
    For example, if the custom field value is “https://domain.com” then I would like https://domain.com to appear on the front end, so the anchor text is “https://domain.com” and the hyperlink itself will point to “https://domain.com”

    So I went to ACF and created a URL custom field, I named it homepage_url.

    Then I saw a new URL custom field in back end, I added the value “https://Venaas.no” into the new URL custom field.

    Now, all I want is to be able to insert the value of this new custom field and display it on the front end, using ACF SHORTCODE.

    So I open the post editor and added the following code:
    <a href="[acf field='homepage_url']" target="_blank" rel="noopener">[acf field='homepage_url']</a>

    But when I looked at the result, I saw that now I have regular plain text on the page, not hyperlink. The regular plain text display (correctly) the value https://Venaas.no, but its a plain text, I would like it also to be a hyperlink that actually links to https://Venaas.no

    How can I do just that?
    I assume that the problem is with the following string: href=”[acf field='homepage_url'], how should a correct string look like?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.