public function modifyFilters($posttype)
    {
        // first check we are working with the this PostType
        if ($posttype === $this->name) {
            // calculate what filters to add
            $filters = $this->getFilters();

            foreach ($filters as $taxonomy) {
                // if the taxonomy doesn't exist, ignore it
                if (!taxonomy_exists($taxonomy)) {
                    continue;
                }

                // get the taxonomy object
                $tax = get_taxonomy($taxonomy);

                // get the terms for the taxonomy
                $terms = get_terms([
                    'taxonomy' => $taxonomy,
                    'orderby' => 'name',
                    'hide_empty' => false,
                ]);

                // if there are no terms in the taxonomy, ignore it
                if (empty($terms)) {
                    continue;
                }

                // start the html for the filter dropdown
                $selected = null;

                if (isset($_GET[$taxonomy])) {
                    $selected = sanitize_title($_GET[$taxonomy]);
                }

                $dropdown_args = [
                    'option_none_value' => '',
                    'hide_empty'        => 0,
                    'hide_if_empty'     => false,
                    'show_count'        => true,
                    'taxonomy'          => $tax->name,
                    'name'              => $taxonomy,
                    'orderby'           => 'name',
                    'hierarchical'      => true,
                    'show_option_none'  => "Show all {$tax->label}",
                    'value_field'       => 'slug',
                    'selected'          => $selected
                ];

                wp_dropdown_categories($dropdown_args);
            }
        }
    }
public function modifyFilters($posttype)
    {
        // first check we are working with the this PostType
        if ($posttype === $this->name) {
            // calculate what filters to add
            $filters = $this->getFilters();

            foreach ($filters as $taxonomy) {
                // if the taxonomy doesn't exist, ignore it
                if (!taxonomy_exists($taxonomy)) {
                    continue;
                }

                // get the taxonomy object
                $tax = get_taxonomy($taxonomy);

                // get the terms for the taxonomy
                $terms = get_terms([
                    'taxonomy' => $taxonomy,
                    'orderby' => 'name',
                    'hide_empty' => false,
                ]);

                // if there are no terms in the taxonomy, ignore it
                if (empty($terms)) {
                    continue;
                }

                // start the html for the filter dropdown
                $selected = null;

                if (isset($_GET[$taxonomy])) {
                    $selected = sanitize_title($_GET[$taxonomy]);
                }

                $dropdown_args = [
                    'option_none_value' => '',
                    'hide_empty'        => 0,
                    'hide_if_empty'     => false,
                    'show_count'        => true,
                    'taxonomy'          => $tax->name,
                    'name'              => $taxonomy,
                    'orderby'           => 'name',
                    'hierarchical'      => true,
                    'show_option_none'  => "Show all {$tax->label}",
                    'value_field'       => 'slug',
                    'selected'          => $selected
                ];

                wp_dropdown_categories($dropdown_args);
            }
        }
    }
public function modifyFilters ( $ posttype ) { // first check we are working with the this PostType if ( $ posttype === $ this -> name ) { // calculate what filters to add $ filters = $ this -> getFilters ( ) ; foreach ( $ filters as $ taxonomy ) { // if the taxonomy doesn't exist, ignore it if ( ! taxonomy_exists ( $ taxonomy ) ) { continue ; } // get the taxonomy object $ tax = get_taxonomy ( $ taxonomy ) ; // get the terms for the taxonomy $ terms = get_terms ( [ 'taxonomy' => $ taxonomy , 'orderby' => 'name' , 'hide_empty' => false , ] ) ; // if there are no terms in the taxonomy, ignore it if ( empty ( $ terms ) ) { continue ; } // start the html for the filter dropdown $ selected = null ; if ( isset ( $ _GET [ $ taxonomy ] ) ) { $ selected = sanitize_title ( $ _GET [ $ taxonomy ] ) ; } $ dropdown_args = [ 'option_none_value' => '' , 'hide_empty' => 0 , 'hide_if_empty' => false , 'show_count' => true , 'taxonomy' => $ tax -> name , 'name' => $ taxonomy , 'orderby' => 'name' , 'hierarchical' => true , 'show_option_none' => "Show all {$tax->label}" , 'value_field' => 'slug' , 'selected' => $ selected ] ; wp_dropdown_categories ( $ dropdown_args ) ; } } }
Modify and display filters on the admin edit screen
@param  string $posttype The current screen post type
@return void
Modify and display filters on the admin edit screen