Home › Forums › General Issues › Display a linkable URL and Remove the comma › Reply To: Display a linkable URL and Remove the comma
Just for a future example, because I found this on a search, the latest Elementor is really having major issues with the Link field in ACF — and if you are creating something for your clients Link is way better than URL ( url meaning the client would have to hard enter the correct url address ).
As stated earlier you’ll have to write a shortcode function in your theme ( function.php )…and then, unfortunately, it doesn’t seem as if the native shortcode link function works ( [acf field='my_link'] doesn’t work ).
Something like this:
function get_acf_link_url($atts) {
$atts = shortcode_atts(array(
'field' => '',
), $atts);
$url = get_field($atts['field']);
return "<a href='" . esc_url($url) . "'>" . esc_html($url) . "</a>";
}
add_shortcode('acf_link_url', 'get_acf_link_url');
And then create a html snippet ( not a Heading or a Text Field ):
<a href="[acf_link_url field='my_link']">Link</a>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.