Support

Account

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.