wp_dropdown_categories with custom taxo goes to 404
-
I have tried a couple solutions to get a dropdown of custom taxonomy terms that link to entries with the selected term.
I have tried a number of solutions I found in the codex and forums, shown below, and keep getting 404s as the results pages when the link resolves.
<form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get"> <?php $args = array( 'taxonomy' => 'location', 'show_option_none' => __( 'Select category' ), 'show_count' => 1, 'orderby' => 'name', 'echo' => 0, ); ?> <?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; ?> <noscript> <input type="submit" value="View" /> </noscript> </form>
<?php wp_dropdown_categories('taxonomy=location&show_option_none=Select location'); ?> <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>
<form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get"> <?php wp_dropdown_categories( 'taxonomy=location&show_option_none=Select location' ); ?> <input type="submit" name="submit" value="view" /> </form>
I deactivate all plugins except the custom plugin with the CPT and taxonomies. I set permalinks to plain and back to pretty. I tested with the Twenty Fifteen theme. All had the same result, 404.
How can I fix this?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘wp_dropdown_categories with custom taxo goes to 404’ is closed to new replies.