Filter custom post types in admin not working

Basically you are doing every thing right except the taxonomy slug in the url should be lowercase so you can simply place this line:

esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'Service' => $term->slug ), 'edit.php' ) ),

with this:

esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'service' => $term->slug ), 'edit.php' ) ),

and you should be fine.

And here is a bonus to get a dropdown as a filter as well:
enter image description here

// Adding a Taxonomy Filter to Admin List for a Custom Post Type
add_action( 'restrict_manage_posts', 'my_restrict_manage_posts' );
function my_restrict_manage_posts() {

    // only display these taxonomy filters on desired custom post_type listings
    global $typenow;
    if ($typenow == 'portfolio') {

        // create an array of taxonomy slugs you want to filter by - if you want to retrieve all taxonomies, could use get_taxonomies() to build the list
        $filters = array('Service');

        foreach ($filters as $tax_slug) {
            // retrieve the taxonomy object
            $tax_obj = get_taxonomy($tax_slug);
            $tax_name = $tax_obj->labels->name;

            // output html for taxonomy dropdown filter
            echo "<select name="".strtolower($tax_slug)."" id='".strtolower($tax_slug)."' class="postform">";
            echo "<option value="">Show All $tax_name</option>";
            generate_taxonomy_options($tax_slug,0,0,(isset($_GET[strtolower($tax_slug)])? $_GET[strtolower($tax_slug)] : null));
            echo "</select>";
        }
    }
}

function generate_taxonomy_options($tax_slug, $parent="", $level = 0,$selected = null) {
    $args = array('show_empty' => 1);
    if(!is_null($parent)) {
        $args = array('parent' => $parent);
    }
    $terms = get_terms($tax_slug,$args);
    $tab='';
    for($i=0;$i<$level;$i++){
        $tab.='--';
    }
    foreach ($terms as $term) {
        // output each select option line, check against the last $_GET to show the current option selected
        echo '<option value=". $term->slug, $selected == $term->slug ? " selected="selected"' : '','>' .$tab. $term->name .' (' . $term->count .')</option>';
        generate_taxonomy_options($tax_slug, $term->term_id, $level+1,$selected);
    }

}

Leave a Comment