Skip to content

Instantly share code, notes, and snippets.

@gavin310
gavin310 / custom_taxonomy_filter.php
Created February 3, 2022 06:40
Output admin post listing taxonomy filter since wp_dropdown_categories is so limited
public static function add_admin_post_listing_taxonomy_filter( string $post_type, string $taxonomy_name, bool $select_current = false, bool $show_count = true, bool $hide_empty = true )
{
add_action( 'restrict_manage_posts', function( $cur_post_type ) use ( $post_type, $taxonomy_name, $select_current, $show_count, $hide_empty ) {
global $wpdb;
if ( $post_type !== $cur_post_type ) {
return;
}
$taxonomy = get_taxonomy( $taxonomy_name );