wp_dropdown_categories with slug in URL
-
Hellow guys !
I have made a wp_dropdown_categories to made a search/find by category but i can’t find out how to use ?cat=slug of my cat, in the url well i use the value of the selected to populate the url that’s good but what is output is not all the post for that category… but no search/find is done.
With something like ?cat=1 it work well but not with ?cat=slug name of my cat<form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/episodes-au-hasard/' ) ); ?>" method="get"> <?php $args = array( 'show_option_all' => 'TOUTES LES SéRIES', 'show_count' => false, 'orderby' => 'name', 'echo' => 0, 'hide_if_empty' => 1, 'value_field' => 'slug', 'hierarchical' => 1, 'depth' => 1, 'selected' => htmlspecialchars($_GET["cat"]), 'name' => 'serie', 'id' => 'serie-cat-aleatoire', ); ?> <?php $select = wp_dropdown_categories( $args ); ?> <?php $replace = "<select$1 onchange='return this.form.submit()'>"; ?> <?php $select = preg_replace( '#<select([^>]*)>#', $replace, $select ); ?> <?php echo $select; ?> </form>
Thanks in advance !
- The topic ‘wp_dropdown_categories with slug in URL’ is closed to new replies.