I followed this link tutorial perfectly, except why when I try to add 2 dropdowns of 2 different taxonomy, a bug occurs and nothing works anymore. What should I do to work?
* I've already changed the names of IDs and JS variables, and it did not work.
Follow my changed code.
Thank you.
<?php $args = array(
'show_option_all' => 'UF',
'taxonomy' => 'estado',
'walker' => new categoryDropdown
);
wp_dropdown_categories( $args );
?>
<script type="text/javascript"><!--
var dropdownEstado = document.getElementById("cat-estado");
function onCatEstadoChange() {
if ( dropdownEstado.options[dropdownEstado.selectedIndex].value != '0' ) {
location.href = "<?php echo esc_url( home_url( '/' ) ); ?>/?estado="+dropdownEstado.options[dropdownEstado.selectedIndex].value;
}
}
dropdownEstado.onchange = onCatEstadoChange;
--></script>
<?php $args = array(
'show_option_all' => 'Tipo',
'taxonomy' => 'tipo',
'walker' => new categoryDropdownEstado
);
wp_dropdown_categories( $args ); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("cat");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value != '0' ) {
location.href = "<?php echo esc_url( home_url( '/' ) ); ?>/?tipo="+dropdown.options[dropdown.selectedIndex].value;
}
}
dropdown.onchange = onCatChange;
--></script>