1

I have Created a text Field (ACF) that contains an URL and would like to re-use this URL for href link, but the code below doesnt work for me:

<?php
function resource_download_button() { 
 
$url = get_field('resource-download'); 
$button = '<a class="vc_general vc_btn3 vc_btn3-size-md vc_btn3-shape-rounded vc_btn3-style-modern vc_btn3-color-danger" href="'.$url.'" target="_new">Download</a>';

return $button;
}

echo resource_download_button();

?>

Could you help please to solve this issue please ?

I tried to change the field type to URL and Link but the problem wasn't solved

  • Welcome to Stack Overflow! Are there errors? "Doesn't work" isn't helpful, since we can't see your code. However, looking at your code, the ACF field should be `_` underscore separated - `resource_download`, not a `-` hyphen. Also, what is that field attached to? A post, page, options? And finally `_new` isn't a valid `target` attribute, you should use `_blank`. – disinfor Jul 29 '23 at 15:21

0 Answers0