I'm modifying a WP category dropdown nav function I found on this site... it returns the categories in the "ugly" way (/?cat=#) which then redirects because I have permalinks enabled, but you can see the flash of the url changing because of the redirect and I don't want that. I would rather the javascript function create the permalink structure I already have, ie. domain.com/category-slug/. So since I have the category ID from the wp_dropdown_categories() function I need to get the category slug from that.
This is the code I have now (that renders the urls in the "ugly" way):
<?php wp_dropdown_categories('show_option_none=Channels&hierarchical=1&orderby=name&exclude=14,33,77,78'); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("cat");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home');?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
}
}
dropdown.onchange = onCatChange;
--></script>
"dropdown.options[dropdown.selectedIndex].value" is the code returns the category ID from the wp_dropdown_categories() function. How would I switch it to something like:
location.href = "<?php echo get_option('home');?>/<?php echo category_slug('catID');?>;