Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author WPLake

    (@wplakeorg)

    Hi @alonagomez

    You’d need to modify the HTML Markup.
    Then include ‘target=”_blank”‘ as part of the link field div.

    Thread Starter alonagomez

    (@alonagomez)

    Please provide detail how to insert that code below.

    <div class="acf-view acf-view--id--15639 acf-view--object-id--{object-id}">
    
    	<!--$facebook_url$-->
    	<div class="acf-view__row acf-view__facebook_url">
    		<div class="acf-view__field">$facebook_url$</div>
    	</div>
    	<!--$facebook_url$-->
    </div>
    Plugin Author WPLake

    (@wplakeorg)

    Hi @alonagomez

    My previous comment was incorrect, you won’t need to modify the HTML. Sorry about that.

    If you’re using a ACF Link field type, then you’d need to tick the ‘Open link in new tab’ in the dialogue when filling the field.

    Thread Starter alonagomez

    (@alonagomez)

    I know this checkbox to open in new tab while filling the fields. Unfortunately, my users don’t know it and I am using a Form. I hope you can provide a snippet to open in new tab without ticking to be Fool-Proof.

    Plugin Author WPLake

    (@wplakeorg)

    Hi @alonagomez

    Aah I understand, to always have the field open in new tab you can paste the following in your functions.php file.
    Replacing ‘INSERT_FIELD_NAME’ with your field name.

    add_filter('acf_views/view/field_markup/name=INSERT_FIELD_NAME', function ($fieldHTML, $fieldMeta, $fieldValue, $viewId) {
        return str_replace('href', 'target="_blank" href', $fieldHTML);
    }, 10, 4);
    Thread Starter alonagomez

    (@alonagomez)

    Thanks it worked.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Open Link Field in New Tab’ is closed to new replies.