只需使用selected
参数:
wp_dropdown_categories( array(
\'show_option_all\' => \'All Deployments\',
\'hierarchical\' => true,
\'show_count\' => true,
\'selected\' => get_query_var( \'cat\' ),
));
Update: 钩住
tag_link
&过滤器;添加当前类别(如果适用):
add_filter( \'tag_link\', \'wpse_71874_tag_link_category_context\' );
function wpse_71874_tag_link_category_context( $link ) {
if ( is_category() && $cat_id = get_queried_object_id() )
$link = add_query_arg( \'cat\', $cat_id, $link );
return $link;
}