Home › Forums › General Issues › Link to post or url?
I see there’s relational fields and a url field.
It would be awesome if we could combine them for times where it may be a link to something external, or a media library file, or a post etc.
Right now we’re leaving them all as urls because that should work for all cases, but could be a problem if we have a multi-domain site and isn’t as maintainable in the longrun (always ideal to reference a specific page).
I guess I could set this up manually for all the url fields we have, but that will be quite repetitive and maybe inconsistent

This has been requested many times and I think it’s low on the priority list. The best way to handle this is to have 3 fields. The first a radio field to select either to add a page link or a URL. Then the other two fields use conditional logic. Once this is set up
if (get_field('radio') == 'page_link') {
// code for page link
} else {
// code for url
}
I think that this is the main reason that it may be low on the developer’s “To Do” list, because with very little work it’s easy enough to accomplish. Basically this does exactly what a field that allows either a page link would need to do even if it were built in.
Yeah I will probably do it that way, thanks! I can see it being requested often as it gets quite repetitive, especially if we also want to accept file uploads and its in multiple places

There is a new “Clone” field type in in the works for ACF Pro that will let you create a group of fields like this and then use them in other field groups. It’s still a bit buggy and I don’t know when it will be completed.
The topic ‘Link to post or url?’ is closed to new replies.
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.