Just specify your own taxonomy as one of the arguments in the passed array. It defaults to category, but can be overridden.
array( 'echo' => 0,
'taxonomy' => 'regions' )
Depending on the taxonomy, other arguments may be needed, like if it’s hierarchical. You can add any arguments that would be accepted by get_terms(), which is how wp_dropdown_categories() retrieves data from the database.
Glad to know it is that simple!
I now discovered a need to take this one step further. I required the name of the input field to be in this format:
name="scrape[<?php echo $inpCnt; ?>][sponsors]"
Given that my code looks like this:
<?php
$sponsors = wp_dropdown_categories( array(
'child_of' => 0,
'class' => 'postform',
'depth' => 0,
'echo' => 0,
'exclude' => '',
'hide_empty' => false,
'hide_if_empty' => false,
'hierarchical' => true,
'order' => 'ASC',
'orderby' => 'name',
'selected' => 0,
'show_count' => 0,
'show_option_all' => '',
'show_option_none' => __(''),
'tab_index' => 0,
'taxonomy' => 'sponsors', )
);
$sponsors = str_replace(
"name='cat' id=",
"name='cat[]' multiple='multiple' size='19' id=",
$sponsors
);
?>
How do I do it?
Do you mean the <select>
tag for drop down lists? You would add
'name' => "scrape[$inpCnt][sponsors]",
to the array definition. But if scrape is a javascript array, this will not work unless the whole thing is being echoed into a script block.
Not PHP without a $ in front, nor inside quotes. If the ‘name’ element is to be assigned a value in the array $scrape it should look like this:
'name' => $scrape[$inpCnt]['sponsors'],
you were correct the first time, thanks!