Home › Forums › General Issues › Display a linkable URL and Remove the comma
Hello
I’ve been using ACF and a few things have got me stumped.
1st
I have a site setup in elementor and have tried using the URL and Link fields in ACF to allow users to put in a website domain in a field for a member profile.
However when ever it displays via ACF shortcode, the url is not linkable, how do i make it link to the URL thats been put in the ACF field?
2nd
https://www.cider.ordesign.me/member/westons/
How do i remove the commas between the icons, under whats on offer?
Thanks
managed to sort the comma, but how do you get the URL to display or link correctly?
https://www.cider.ordesign.me/member/barbourne-cider/
This cannot be done using just ACF unless you build your own shortcode. You may want to direct your question at elementor. But I can’t say because there’s not enough information about how where or how you are attempting to output the URL.
In ACF I have a field with “url” as the type.
Which then appears in the custom post for the user to put in a url.
Then on the page, which is built with elementor, I am using ACF shortcode to display the url as I couldn’t do it via the normal way in elementor.
I was told to put the shortcode in an <a href but it didn’t work or only half works.
a href=”<?= website(‘my_link’) ?>”>[acf field="website"]
I am guessing the “my link” bit would be the url but I don’t want to manually put that in each time. So at which point I got stuck.
I would like the url to display as it does and then link to the site.
You cannot use shortcodes for the href value. This will not work.
<a href="[acf field="website"]">[acf field="website"]</a>
You can also not use PHP as you’ve done in your code.
Neither of these methods are supported by WP.
The only way to do this is to create a custom shortcode that outputs the entire link.
Ok, so what is the “URL” field type used for in ACF? Should i be using something else?
Is there a shortcode already setup to do what i am trying to achieve?
I came across this problem which is similar to what i want to do and you talk about using a text field with custom validation. So do your text fields contain a url that a user puts in, which the url is displayed on website frontend and is also clickable/linkable to the relevant url?
How do i achieve that?
The issue is that you’re using elementor. I do not use elementor or any other tool/plugin that does my coding for me. If I want to use a field as a link I open the php file where it will be used and add something like
<a href="<?php the_field('my-url-field'); ?>">Link Text Here</a>
ACF does not have anything built in that will do this for me.
When using another tool to do coding for you then any questions related to how to use a particular field should be addressed to the author of that tool.
As far as using a text field or some other type of field, I do not know how the person in the other thread managed to use a text field, because, again, I don’t use elementor. You might want to try posting a comment in that thread and asking him for more information about how it was done. He does supply a link to get more information from.
I am using elementor but i was using the ACF shortcode like you use it in wordpress so elementor isnt a problem.
Im new to ACF, so i was trying to understand how to create a clickable link. Looking at the field types in ACF, URL looks like the one you use for someone to fill in a url and then on the front end it appears for someone to click on.
But looking at your answer on the post i linked, it seems otherwise, plus your answer saying…
“Just a little off topic, but I don’t use URL fields much. I basically always use a text field. URL fields are too limiting. I want to allow users to enter any valid href value, so I use a text field and then add custom validation to to it.”
So reading the original post and then your reply to it, sounds like you use a text field with some custom code to allow users to fill in a url in the backend for it to display on the frontend of the website and allow visitors to click it, am i right in thinking this?
There isn’t any way to use a shortcode to do what you want to do, it just is not possible in WP and ACF’s shortcode is only for simple text fields. To accomplish this you would need to create your own custom shortcode. https://developer.wordpress.org/reference/functions/add_shortcode/
Not sure if anyone is still looking for a quick fix, just use the “Icon List” element to pull the ACF field for the title and link and remove the icon if you don’t want it to show.
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>
Sorry – in that case if you used that snippet you’d just return the escaped url.
return esc_url($url);
Ladykiller.nl is
Nederlands meest toonaangevende seksshop. Wij zijn gespecialiseerd in het verstrekken van verschillende soorten seksspeeltjes voor mannen, vrouwen, lesbiennes of homo’s. We hebben een enorme verscheidenheid van speeltjes zodat iedereen zijn of haar behoeften kan bevredigen. Daarnaast hebben wij ook een uitgebreide categorie met bondage speeltjes en bdsm speeltjes om ook de stoutste onder ons te plezieren.
You must be logged in to reply to this topic.
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.