Hello there guys, I have this idea of displaying all the categories as a <select> and on click go to the category. I'm not familiar with wordpress tags, so I was wondering: <div id="categoryselect"> <form> <select> {FOR EACH CATEGORY}<option value={CATEGORY}>{CATEGORY}</option> </select> </form> </div> No idea what to edit, and also if you know the javascript for automatically redirect upon click on any option, without any submit button. I believe I need value=URL. Thank you,
try this <?php wp_dropdown_categories('arguments'); ?> PHP: example <?php wp_dropdown_categories(); ?> PHP: using javascript <li id="categories"><h2><?php _e('Posts by Category'); ?></h2> <?php wp_dropdown_categories('show_option_none=Select category'); ?> <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> </li> PHP: another method <li id="categories"> <h2><?php _e('Posts by Category'); ?></h2> <form action="<?php bloginfo('url'); ?>/" method="get"> <?php $select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0'); $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); echo $select; ?> <noscript><input type="submit" value="View" /></noscript> </form> </li> PHP: source : http://codex.wordpress.org/Template_Tags/wp_dropdown_categories
Works like a charm,though I have to ask if you know if <select> can have a background:url, I'm trying to stylize it a bit, not having much success.