0

how to disable autocomplete search on wpLink?

autocomplete search

4
  • Can I ask why you'd want to do this? Commented Oct 23, 2018 at 12:55
  • hi, because i use wp_editor in the front end, i don't want show autocomplete search to register user.
    – kian
    Commented Oct 24, 2018 at 1:32
  • i have try add this code but it doesn't work for me, my site go blank. uebbi.com/wordpress-disable-autocomplete-on-wplink
    – kian
    Commented Oct 24, 2018 at 1:44
  • update: problem solved.
    – kian
    Commented Oct 26, 2018 at 1:29

1 Answer 1

0

OP linked it in a comment above, but here's the code used.

Note This doesn't actually disable autocomplete, it simply removes all of the results before they're displayed (and I added some CSS to hide the loading icon). They're still fetched by WP, just overridden with an empty array.

add_filter( 'wp_link_query', 'remove_results_from_link_builder_autocomplete', 10, 2 );
function remove_results_from_link_builder_autocomplete( $results, $query ) {
    return array();
}

You'll also likely want some CSS to hide the autocomplete loading icon:

input[type=email].ui-autocomplete-loading,
input[type=text].ui-autocomplete-loading {
    background-image: none;
}

If you're also removing this functionality in the Link Builder popup editor (after you click the gear icon), here's some additional CSS to hide the whole search section.

#wplink-link-existing-content,
#search-panel {
    display: none;
}
#wp-link-wrap {
     height: 225px;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.