Home Forums Feature Requests Link to page or url


Link to page or url

  • I’m not sure if this is a wordpress thing or ACF but I need a be able to add a link that could be to either a page, url, email or to a file.

    A selector with the page list but also has a field / place for entering a url etc. Obliviously only one could be selected. I’ve had to resort to using the url field and telling them to get the url of what they need to link to.

    The insert link in the WYSIWYG editor works roughly how I’m suggesting but with an option for mailto links too.

    As an addition it would also be nice if you could select a user and it uses their email address in a mailto (if they changed their email address then it would update too).

  • For your links issue, you could handle this easily with just a little extra php and a few more ACF fields.

    Create a “Select field to your form, and give it the options that you’d like, such as URL, Page, Email, and File.

    Next, you’ll create a text input for the URL, and at the bottom of the field options, select “Yes” for “Conditional Logic”. This will show a new section, and you can set this field to only show when the selected value of your drop down is equal to “URL” (it auto-populates the available choices for you).

    Do the same thing when creating a “Page Link” relational field, “File” content field, and another text field for the email (you can set this text field up to validate the input to make sure it’s an email), and set their conditional logic appropriately.

    Now when a user needs to add one of those to a page, they use the dropdown select field to select the type of link they’ll be adding, and the appropriate field will be shown to them. You could even do this inside of a repeated field so that they could add multiple links if that would work with your use-case.

    In your theme files where you need to display these links, you would check to see if any selection was made, then get the data from the proper field based on which selection was made and build the link.

    If you wanted to allow them to select a user, and get their email automatically for the field, you could use the “User” relational field type, and then in your template use the data returned to get the user’s email (I’m not sure offhand if this field returns an object or just the user id though, so you’d have to play around with it).

  • Hi

    That’s the best solution for the moment.. although it would be nice to have it built in.

    I’ll have to work out the php but I’m sure I can manage that.


Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Link to page or url’ is closed to new replies.