I need to remove the auto adding of   in the wp_dropdown_categories, it causes a problem in the jQuery multi select dropdown plugin I'm using.

Example value:

<option class="level-1" value="120">&nbsp;&nbsp;&nbsp;Apples&nbsp;&nbsp;(125)</option>

You could use the echo parameter to return the output into a variable:

$html =  wp_dropdown_categories( array( 'echo' => 0 ) );

and then replace &nbsp;:

echo str_replace( '&nbsp;', '', $html );
  • Thanx, How do I add "<select multiple="multiple">" to the form select elements? – Naveen Narale Jul 17 '13 at 10:39
  • 1
    You could do similar replace: $html = str_replace('<select', '<select multiple="multiple"', $html ); – birgire Jul 17 '13 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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