i have a function of custom taxonomies to display a drop down list on my website, which is working fine, but there is one problem, the default value is a custom taxonomy, but that i dont want, i want a custom word, like select cause the current default value, when i select it, it is not redirecting to the corresponding page,
if you wanna chaeck it, goto my website, on the home page i have kept that drop-down list
www.mbas.in
and the code of the function is
function the_taxonomy_dropdown($taxonomy) {
$id = "{$taxonomy}-dropdown";
$js =<<<SCRIPT
<script type="text/javascript">
jQuery(document).ready(function($){
$("select#{$id}").change(function(){
window.location.href = $(this).val();
});
});
</script>
SCRIPT;
echo $js;
$terms = get_terms($taxonomy);
echo "<select name="{$id}" id="{$id}">";
foreach($terms as $term) {
echo '<option value="';
echo get_term_link(intval($term->term_id),$taxonomy);
echo '">' . "{$term->name}</option>";
}
echo "</select>";
}
add_action('init','jquery_init');
function jquery_init() {
wp_enqueue_script('jquery');
}
what i do for keeping default value as Select ????
Not sure exactly what you’re asking. Do you just want to include a blank value before the list of terms? Would this work:
(inserted just before the line foreach($terms as $term) {)