filter on the admin table

filter on the admin table

// this hook will create a new filter on the admin area for the specified post type
add_action( 'restrict_manage_posts', function($post_type){
    if ($post_type != 'contact') {
        return;
    }

    $group_terms = get_terms(array(
      'taxonomy' => 'group',
      'hide_empty' => true,
       ));
    if (count($group_terms) != 0) {
        echo '<select name="group"><option value="">Alle Gruppen</option>';
        foreach ($group_terms as $term) {
            echo '<option value="' . $term->slug . '">' . $term->name . '</option>';
        }
        echo '</select>';
    }
});

 

Share this post

Share on facebook
Share on twitter
Share on pinterest
Share on email