I'm using the below code to list categories as hierarchical. On change of select options it is redirecting to the respective category pages. But it not showing the category as selected.Could any one help me on this please?
$terms = wp_dropdown_categories(array(
'taxonomy' => 'news-categories',
'hierarchical' => 1,
'show_option_none' => "CATEGORIES",
'option_none_value' => "",
'name' => 'news_cat_name',
'id' => 'cat_search',
'value_field' => 'slug',
'selected' => 1,
));
JavaScript:
$('#cat_search').change(function () {
if ($(this).val()) {
window.location = "<?php echo esc_url(home_url('/')); ?>news-categories/" + $(this).val();
}
});