Thanks a lot for the answer! It ended up being more complicated than it seemed though.
Those wp_dropdown_categories snippets were creating urls based on the IDs of the event categories (e.g https://www.mysite.com/?event-categories=3) which don’t exist. Fortunately I also found this answer that complemented yours.
In case someone stumbles upon this, here’s what worked for my drop down events category menu that submits on select.
<?php
function replace_id_for_slug($option){
$categories = get_categories("taxonomy=event-categories&hide_empty=0");
preg_match('/value="(\d*)"/', $option[0], $matches);
$id = $matches[1];
$slug = "";
foreach($categories as $category){
if($category->cat_ID == $id){
$slug = $category->slug;
}
}
return preg_replace("/value=\"(\d*)\"/", "value=\"$slug\"", $option[0]);
}
$select = wp_dropdown_categories("taxonomy=event-categories&hierarchical=1&hide_empty=0&echo=0&show_option_none=Select category");
$select = preg_replace_callback("#<option[^>]*>[^<]*</option>#", "replace_id_for_slug", $select);
echo $select;
?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("cat");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value != -1 ) {
location.href = "<?php echo get_option('home');?>?event-categories="+dropdown.options[dropdown.selectedIndex].value+"/";
}
}
dropdown.onchange = onCatChange;
--></script>