Comment on page

Open link in new tab

When using fields that display a link for example a URL, File or Image field and you want it open in a new tab.

Code Snippet in Functions.php

To always have links open in a new tab. Copy and paste the following code into your functions.php file.
// acf field to open in new tab
add_filter('acf_views/view/field_markup/name=YOUR_FIELD_NAME_HERE', function ($fieldHTML, $fieldMeta, $fieldValue, $viewId) {
return str_replace('href', 'target="_blank" href', $fieldHTML);
}, 10, 4);
Replacing 'YOUR_FIELD_NAME_HERE' with the Name of your field or repeater subfield.