Home › Forums › General Issues › How to add an anchor link with Advanced Custom Fields › Reply To: How to add an anchor link with Advanced Custom Fields
On Line 29, you likely need to:
1) Not close the div at the end as that div should wrap around the entire lightbox content so move the closing div tag to the end of your lightbox content
2) As I mentioned earlier, you are storing the custom field value with a hash in your ACF field so it’s something like #flavorname. How anchors work is a #flavorname would be looking for an ID of just “flavorname” (no hash) so right now you’re spitting out the full #flavorname in both spots. It would probably be better if you move to a text ACF field vs URL and store the value without the # so the user is inputting just “flavorname” in the backend. Then in the linked part, add the hash there manually. Or you could leave the fields as is but use something like str_replace to replace the hash in the subfield in the ID spot.
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.