wp_dropdown_categories with multiple select

wp_dropdown_categories has a filter applied to the output that is called right before the function returns or echos the output.

With this you can add a filter to your funtions.php file that manipulates the select field and adds a multiple attribute to it.

The filter below would search for the select opening tag and add the multiple attribute to it. You can also add the size attribute to control the number of items displayed at a time.

add_filter( 'wp_dropdown_cats', 'dropdown_filter', 10, 2);

function dropdown_filter( $output, $r ) {
    $output = preg_replace( '/<select (.*?) >/', '<select $1 size="5" multiple>', $output);
    return $output;
}

Leave a Comment