Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#16734 new enhancement

Allowing multiple selection when using wp_dropdown_categories

Reported by: grandslambert Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.1
Component: Taxonomy Keywords: has-patch dev-feedback
Focuses: Cc:


I would like to be able to pass an argument to wp_dropdown_categories() to allow the user to select more than one category using a CTRL-CLICK. I can use a preg_replace to add the multiple tag to the html select tag, but I cannot pass multiple selections in the "selected" argument.

I modified two files (wp-includes/category-template.php and wp-admin/css/wp-admin.css) to add this option and will include patches for these files. It adds a boolean argument for "multiple" to wp_dropdown_categories and uses in_array to check if terms are listed in an array in the "selected" argument, casting it as an array if it is not. I have tested this patch to work in the latest trunk (3.1).

The change in the w-admin.css is so the multiple selection box is tall enough to show the slider and more than one category.

Attachments (2)

category-template.php.diff (1.6 KB) - added by grandslambert 3 years ago.
Change in the category-template.php to support multipe select boxes.
wp-admin.css.diff (115.1 KB) - added by grandslambert 3 years ago.
Change in the wp-admin.css to add a class to make the multiple select taller.

Download all attachments as: .zip

Change History (10)

grandslambert3 years ago

Change in the category-template.php to support multipe select boxes.

grandslambert3 years ago

Change in the wp-admin.css to add a class to make the multiple select taller.

comment:1 greuben3 years ago

I don't know how useful this feature will be but for css and javascript files you need to submit a patch using their respective .dev files.

comment:2 grandslambert3 years ago

I am working on some plugins and want people to be able to select multiple categories. I tried to use the checkboxes like on the post page but there does not seem to be a really useful method for creating those that I can find. I played around with wp_terms_checklist() but could not get it to accept my selected categories - it just checked whatever it felt like checking. I need to use this in a widget form.

comment:3 prionkor2 years ago

@grandslambert: Ability to have multiple selection should be added. I am absolutely with you!

The feature can be something like adding an extra argument array which we can call attribute array. This way we can add id, classes, multiple or any other attribute on the select field.

Last edited 2 years ago by prionkor (previous) (diff)

comment:4 prionkor2 years ago

  • Keywords dev-feedback added
  • Version changed from 3.1 to 3.3

comment:5 SergeyBiryukov2 years ago

  • Version changed from 3.3 to 3.1

Version field indicates when the enhancement was initially suggested.

comment:6 Gecka2 years ago

Dear Wordpress Core "Devs",

You really know how to discourage developers to contribute to wordpress. Well done. I found so many little fixes or small nifty additions that never got their way into core or have been rewritten by you, letting behind the original author credit.

The world should know about that!


BTW WP is a great product, I really hope that one day some will fork that project over github and will allow contributing!

comment:7 mbijon2 years ago

(troll-bait taken, admins feel free to delete this comment that has nothing to do with the ticket)

@Gecka, I think the extra discussion that happens here on Trac is vital to keeping WordPress stable and promulgating best practices. Whether core is in SVN or Git it's the discussions here that often refine, change or keep code out of core. And, while there are tools that might be able to parallel what happens on Trac, those are GitHub-specific and not general Git tools.

Besides the core team is working to reduce the hurdles to contributing:

comment:8 nacin3 months ago

  • Component changed from General to Taxonomy
Note: See TracTickets for help on using tickets.