0

My site has a long list of authors. I understand the html is a select list. However, is there any way, javascript or other, to make this a filter-able list, i.e. with a search box at top of the dropdown?

1 Answer 1

0

I don't know if this counts as an answer, but I wanted to share in case it is helpful. It looks like you can, although there's an important caveat in that this method needs some fixing to make work.

Here's a blog post that describes how to set up the Select2 JavaScript library to make the user dropdown searchable.

There's too much code to repeat here, I think, but in short, it works like this:

  1. Hook into the wp_dropdown_users function to include the JavaScript files and replace the HTML with something that will work with #2
  2. Create an AJAX call that can return the list of users into the HTML in #1
  3. Write the JavaScript to integrate the dropdown with Select2 and make the AJAX call

This is conveniently packaged in a plugin available on GitHub, here.

The caveat: It's quite old and doesn't appear to work anymore, but it may only take some debugging to get it going again. In the Block Editor, it does nothing, but in the Classic Editor, it seems to almost work.

Your Answer

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

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