Back to Community

How to Add a Custom Taxonomy Filter to Your WordPress Admin List

25 threads Sep 9, 2025 PluginCustom post type ui

Content

If you've created custom taxonomies with the Custom Post Type UI plugin, you might want to filter your admin list view by those terms to make content management easier. A common question from users is why some newly created taxonomies show a filter dropdown while older ones do not, or how to add this functionality in the first place.

Why This Happens

The Custom Post Type UI plugin handles the registration of your post types and taxonomies. However, the administrative interface for filtering posts by taxonomy is not automatically generated for all taxonomies by WordPress core. The appearance of these filters can depend on several factors, including the order of registration or specific settings. This is not a bug in CPTUI but a standard WordPress behavior that requires a custom code solution.

The Most Common Solution: Custom Code

The most reliable way to add a filter for your custom taxonomy is to add a small code snippet to your theme's functions.php file or a site-specific plugin. This code hooks into the WordPress admin to display a dropdown filter.

Step-by-Step Code Implementation

  1. Access Your Code: Use a code editor and access your theme's functions.php file. We recommend using a child theme to prevent your changes from being overwritten by theme updates.
  2. Add the Filter Code: Copy and paste the following code, making sure to replace 'your_post_type' with your actual custom post type slug and 'your_taxonomy' with your custom taxonomy slug.
    add_action('restrict_manage_posts', 'filter_post_type_by_taxonomy');
    function filter_post_type_by_taxonomy() {
        global $typenow;
        $post_type = 'your_post_type'; // Replace with your post type
        $taxonomy  = 'your_taxonomy';  // Replace with your taxonomy
        if ($typenow == $post_type) {
            $selected      = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
            $info_taxonomy = get_taxonomy($taxonomy);
            wp_dropdown_categories(array(
                'show_option_all' => sprintf( __( 'Show all %s', 'textdomain' ), $info_taxonomy->label ),
                'taxonomy'        => $taxonomy,
                'name'            => $taxonomy,
                'orderby'         => 'name',
                'selected'        => $selected,
                'show_count'      => true,
                'hide_empty'      => true,
            ));
        };
    }
    
    add_filter('parse_query', 'convert_id_to_term_in_query');
    function convert_id_to_term_in_query($query) {
        global $pagenow;
        $post_type = 'your_post_type'; // Replace with your post type
        $taxonomy  = 'your_taxonomy';  // Replace with your taxonomy
        $q_vars    = &$query->query_vars;
        if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
            $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
            $q_vars[$taxonomy] = $term->slug;
        }
    }
  3. Save and Test: Save the file and navigate to your custom post type's list in the WordPress admin. You should now see a dropdown filter for your custom taxonomy.

Important Considerations and Troubleshooting

  • Plugin Conflicts: If the code does not work, try disabling other plugins to rule out a conflict. Another plugin might be interfering with the admin query.
  • Theme Functions: Ensure your theme does not already have conflicting code for admin filters. The code must be added correctly to the functions.php file.
  • Page Builders and Advanced Filters: For more complex filtering needs on the public-facing front end of your site (e.g., for visitors to filter portfolio items), this admin code will not work. The Custom Post Type UI team has often pointed users to third-party solutions like FacetWP for front-end filtering systems.
  • Support Scope: Remember, the Custom Post Type UI plugin registers the taxonomies, but how they are used and displayed in the admin or on the front end is handled by WordPress core, your theme, or other plugins.

By following this guide, you can significantly improve the content management experience for yourself and your clients by making it easy to find and filter content based on custom classifications.

Related Support Threads Support