Home › Forums › General Issues › Link a field to a page or to a category › Reply To: Link a field to a page or to a category
Did you try using a URL field? Or a text field that you can use to enter a URL?
You could also have a field that selects an existing category or page… and output the HTML as needed.
There are a couple different ways to do it… you can choose a field that returns an Object that contains a label and URL… or have two separate fields for that Data for more flexibility. And you can add a 3rd field… a checkbox, asking if the link should open in a new Window..
Lot of choices.
Let me know if you need further help.
p.s. Remember you could use code similar to below to build an anchor tag based on multiple fields:
<a href="<?php echo get_field('url'); ?>" title="<?php echo get_field('url_title'); ?>"<?php echo get_field('url_new_window'); ?>><?php echo get_field('url_anchor_text'); ?></a>
The ‘url_new_window’ field can output target=”_blank” (with a leading space if set to TRUE (or checked) )
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.