Title: Losing selection when editing
Last modified: August 31, 2016

---

# Losing selection when editing

 *  Resolved [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/)
 * Is it possible to retain the link when editing the selection?
 * [https://wordpress.org/plugins/acf-link/](https://wordpress.org/plugins/acf-link/)

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420259)
 * [@metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * Could you please be more specific as to what you are trying to do and what is
   happening?
 * Thank you.
 *  Thread Starter [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420265)
 * Ah, it actually works fine in a custom post. But in an ACF widget, it doesn’t:
 * [http://screencast.com/t/UDXvor3q8iuQ](http://screencast.com/t/UDXvor3q8iuQ)
 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420281)
 * What version of ACF Link and WP are you using? I cannot reproduce this. It could
   be another plugin interfering?
 *  Thread Starter [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420286)
 * The latest versions of both. I’ve disabled all plugins except ACF ones, but it
   still happened. Is this related to trying to use this field in an ACF Widget?
 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420288)
 * Very weird. But no it should work no matter where you include it. What browser
   are you using? Are there any JavaScript errors if you open the browser console?
 *  Thread Starter [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420405)
 * ReferenceError: assignment to undeclared variable $selector
    [http://localhost/AIDSLifeCycle/StagingSite/deploy/web/wp/wp-content/plugins/advanced-custom-fields-pro/assets/js/acf-input.min.js?ver=5.3.8.1](http://localhost/AIDSLifeCycle/StagingSite/deploy/web/wp/wp-content/plugins/advanced-custom-fields-pro/assets/js/acf-input.min.js?ver=5.3.8.1)
   Line 1
 * ReferenceError: reference to undefined property a[b]
    [http://localhost/AIDSLifeCycle/StagingSite/deploy/web/wp/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-resizable&ver=4.5.2](http://localhost/AIDSLifeCycle/StagingSite/deploy/web/wp/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-resizable&ver=4.5.2)
   Line 4
 *  [rgbjoy](https://wordpress.org/support/users/rgbjoy/)
 * (@rgbjoy)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420495)
 * This is still a problem [http://quick.as/yaxi8n14](http://quick.as/yaxi8n14)
 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420497)
 * Can you two please let me know exactly what versions you are using of each of
   the following:
 * WP version
    ACF PRO version ACF Link version
 * As well as your exact browser and version.
 * I cannot reproduce with the following:
 * WP 4.5.3 (alpha)
    ACF PRO 5.3.8.1 ACF Link 1.1.2 Firefox 45.0.1 and Chrome 52.0.2743.10
   dev
 * Thank you.
 *  Thread Starter [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420498)
 * WP: 4.5.2
    ACF Pro: 5.3.8.1 ACF Link: 1.1.2 Firefox: 47.0b9 Chrome: version 50.0.2661.102
   m
 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420501)
 * Thank you. I’ve realized that my plugin was not correctly detecting if the link
   dialog scripts had already been loaded or not and was then loading them twice
   if there was already an editor on the page.
 * Please install this patched version and let me know if it fixes the issue. If
   all is good then I can release a new version right away.
 * Patch: [http://emrl.mx/acf-link-1.1.2-patch.zip](http://emrl.mx/acf-link-1.1.2-patch.zip)
 *  Thread Starter [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420502)
 * It appears to be working. Though now I’m noticing that “open in the same window”
   is adding target=”0″, which is targeting a new tab.
 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420517)
 * Where is it adding target=”0″? The field is saved in the database as either a“
   0” (same window/tab) or “1” (new window/tab), and it is the developers responsibility
   to use that how they see fit. For example:
 *     ```
       <?php
       $link = get_field('link');
       $target = $link['target'] ? ' target="_blank"' : '';
       $a = sprintf('<a href="%s"%s>Link</a>', $link['url'], $target);
       ```
   
 *  Thread Starter [metaglyphics](https://wordpress.org/support/users/metaglyphics/)
 * (@metaglyphics)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420519)
 * Ah! That solves it. Thanks.
 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420520)
 * wordpress.org double posted.
 *  Plugin Author [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * (@coreyw)
 * [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420521)
 * Great. You could always add a filter to format the target how you like. Example:
 *     ```
       add_filter('acf/format_value/type=link', function ($value, $post_id, $field) {
         $value['target'] = $value['target'] ? '_blank' : '_self';
         return $value;
       }, 10, 3);
   
       $link = get_field('link');
       printf('<a href="%s" target="%s">%s</a>', $link['url'], $link['target'], $link['title']);
       ```
   
 * I’ve released a new version (1.1.3) with the previous fixes for the edit functionality.
 * Thank you for your help and patience.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Losing selection when editing’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/acf-link_f7921e.svg)
 * [Advanced Custom Fields: Link](https://wordpress.org/plugins/acf-link/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/acf-link/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/acf-link/)
 * [Active Topics](https://wordpress.org/support/plugin/acf-link/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/acf-link/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/acf-link/reviews/)

 * 15 replies
 * 3 participants
 * Last reply from: [Corey Worrell](https://wordpress.org/support/users/coreyw/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/losing-selection-when-editing/#post-7420521)
 * Status: resolved