Skip to content

Commit

Permalink
Query Filters: Add taxonomy term counts
Browse files Browse the repository at this point in the history
  • Loading branch information
renintw committed Oct 8, 2023
1 parent b11aa4d commit c388405
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,20 @@ function get_category_options( $options ) {
_n( 'Categories <span>%s</span>', 'Categories <span>%s</span>', $count, 'wporg' ),
$count
);
$option_labels = array_map(
function( $name, $count ) {
return $name . " ($count)";
},
wp_list_pluck( $categories, 'name' ),
wp_list_pluck( $categories, 'count' )
);

return array(
'label' => $label,
'title' => __( 'Categories', 'wporg' ),
'key' => 'cat',
'action' => home_url( '/archives/' ),
'options' => array_combine( wp_list_pluck( $categories, 'term_id' ), wp_list_pluck( $categories, 'name' ) ),
'options' => array_combine( wp_list_pluck( $categories, 'term_id' ), $option_labels ),
'selected' => $selected,
);
}
Expand Down

0 comments on commit c388405

Please sign in to comment.