Site logo

Archived topic

acf shortcode in link to pdf

7 replies · Started by Angie on January 4, 2022

Viewing posts 1–8 of 8

Hello!
I've succeeded to insert an acf shortcode as link to a pdf-download in a button in a header element with this code:
<a class="button-download" href='[acf field="dateiupload"]' target="_blank">PDF herunterladen</a>

But I'd rather insert this into a content template. But the same code doesn't work there, when switching to the code editor the code is automatically changed to this:
<a class="button" href="[acf field=&quot;dateiupload&quot;]" target="_blank" rel="noopener">PDF herunterladen</a>

Is there a way to get this working?

Thank you,
Angie.

Hello! This took a while, sorry.

What I did:
GP Button Block with dynamic link type Post Meta >> field name set to "dateiupload" (=ACF-field)
>> In the frontend, the link is not created right. It looks something like this, e.g. http://0.0.21.37/

What could be the reason for this?

Thank you!
Angie.

What type of ACF Field is it ?

file
> file-URL

Hmmm... not sure this will work, but can you change the Return Value to File ID

I solved it differently. I changed the field type to URL (not File URL) and now it works. It will take one step more to fill the field when editing (copy file URL in Media library), but I think that's ok.

Thank you anyway.
Angie.

Glad to hear you found a solution!

This archived topic is closed to new replies.