admin管理员组

文章数量:1193806

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?

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?

Share Improve this question edited Sep 22, 2022 at 10:19 Leora Deans asked Sep 22, 2022 at 10:10 Leora DeansLeora Deans 1911 silver badge10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: adminFiltered dropdown for author