I create 2 dropdowns one for each category & tag
and filtering posts successfully.
After that i create a custom taxonomy cat
and try to filter post between all three dropdowns. But dropdown for taxonomy cat
not working.
<form action="<?php bloginfo('url'); ?>" method="get">
<?php
// I use custom taxonomy "Cat"
if( $terms = get_terms( 'cat', 'orderby=name' ) ) :
echo '<select name="cat_name"> <option value="">Cat</option>';
foreach ( $terms as $term ) :
echo '<option value="' . $term->name . '">' . $term->name . '</option>';
endforeach;
echo '</select>';
endif;
// I use default "Categories"
if( $terms = get_terms( 'category', 'orderby=name' ) ) :
echo '<select name="category_name"> <option value="">Categories</option>';
foreach ( $terms as $term ) :
echo '<option value="' . $term->name . '">' . $term->name . '</option>';
endforeach;
echo '</select>';
endif;
// I use default "Tag"
if( $terms = get_terms( 'post_tag', 'orderby=name' ) ) :
echo '<select name="tag"><option value="">Tags</option>';
foreach ( $terms as $term ) :
echo '<option value="' . $term->name . '">' . $term->name . '</option>';
endforeach;
echo '</select>';
endif;
?>
<input type="submit" name="submit" value="filter" />
</form>
Its not work for taxonomy
cat
& but working for others twocategory & tag
What I missing or any suggestions to make all three dropdown working?
Optional: This is how i create Custom Taxonomy cat
function custom_taxonomies() {
$labels = array(
'name' => 'Cat',
'singular_name' => 'Cat',
'menu_name' => 'Cat'
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'cat' )
);
register_taxonomy('cat', array('post'), $args);
}
add_action( 'init' , 'custom_taxonomies' );