PHPackages                             jorenrothman/wp-admin-filters - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. jorenrothman/wp-admin-filters

ActiveLibrary[Admin Panels](/categories/admin)

jorenrothman/wp-admin-filters
=============================

1.0.7(5mo ago)028MITPHP

Since Oct 1Pushed 5mo agoCompare

[ Source](https://github.com/JorenRothman/wp-admin-filters)[ Packagist](https://packagist.org/packages/jorenrothman/wp-admin-filters)[ RSS](/packages/jorenrothman-wp-admin-filters/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

WP Admin Filters
================

[](#wp-admin-filters)

A modern, Composer-ready WordPress plugin for **contextual admin filters** on custom post types. Easily add dropdown filters for **meta fields**, **taxonomies**, and **custom callbacks** in the admin post list. Includes Select2 for a better UI.

---

✨ Features
----------

[](#-features)

- Add filters to the admin list table for any (custom) post type
- Filter by **meta fields** (auto-discover distinct values or provide options)
- Filter by **taxonomies**
- Add **custom callback filters** with your own query logic
- Select2 dropdowns for better usability

---

📦 Installation
--------------

[](#-installation)

### With Composer (recommended)

[](#with-composer-recommended)

```
composer require jorenrothman/wp-admin-filters
```

Then activate include the mu-plugin some how.

### Manual

[](#manual)

1. Download or clone this repository into `wp-content/mu-plugins/wp-admin-filters`
2. Run `composer install` inside the plugin folder
3. Activate **WP Admin Filters** from the WordPress admin

---

🚀 Usage
-------

[](#-usage)

Register filters inside a hook (e.g. `plugins_loaded`):

```
use JorenRothman\WpAdminFilters\FilterManager;

add_action('plugins_loaded', static function () {
    $filters = new FilterManager('book'); // post type slug

    // Meta filter: ISBN
    $filters->addMetaFilter('isbn', [
        'label' => 'ISBN',
        'key'   => 'isbn', // meta_key
    ]);

    // Meta filter: Post Object/Relationship Field
    $filters->addMetaFilter('items', [
        'label' => 'Items',
        'key'   => 'items', // meta_key
        'resolve_posts' => true,
    ]);

    // Taxonomy filter: Genre
    $filters->addTaxonomyFilter('genre', [
        'label'    => 'Genre',
        'taxonomy' => 'genre',
    ]);

    // Callback filter: Has Reviews
    $filters->addCallbackFilter('has_reviews', [
        'label' => 'Has Reviews',
        'options' => [
            'yes' => 'Yes',
            'no'  => 'No',
        ],
        'apply' => function (\WP_Query $query, $value) {
            if ($value === 'yes') {
                $query->set('meta_query', [[
                    'key'     => 'review_count',
                    'value'   => 0,
                    'compare' => '>',
                ]]);
            }
            if ($value === 'no') {
                $query->set('meta_query', [[
                    'key'     => 'review_count',
                    'value'   => 0,
                    'compare' => '=',
                ]]);
            }
        },
    ]);

    $filters->register();
});
```

Now when you visit the **Books** admin screen, you’ll see the filters above the post list.

---

🔧 API Reference
---------------

[](#-api-reference)

### `FilterManager::__construct(string $postType)`

[](#filtermanager__constructstring-posttype)

Create a filter manager for a custom post type.

### `FilterManager::addMetaFilter(string $key, array $args = [])`

[](#filtermanageraddmetafilterstring-key-array-args--)

Add a meta field filter. Args:

- `label` (string) – Dropdown label
- `key` (string) – Meta key (defaults to `$key`)
- `options` (array) – Optional predefined key → label pairs. If omitted, distinct values are auto-discovered.
- `resolve_posts` (bool) - Transform ids into post titles handy for relationship/post object fields.

### `FilterManager::addTaxonomyFilter(string $key, array $args = [])`

[](#filtermanageraddtaxonomyfilterstring-key-array-args--)

Add a taxonomy filter. Args:

- `label` (string) – Dropdown label
- `taxonomy` (string) – Taxonomy name

### `FilterManager::addCallbackFilter(string $key, array $args = [])`

[](#filtermanageraddcallbackfilterstring-key-array-args--)

Add a custom callback filter. Args:

- `label` (string) – Dropdown label
- `options` (array) – Key → label pairs for dropdown options
- `apply` (callable) – Function `fn(WP_Query $query, string $value)` that applies custom query logic

### `FilterManager::register()`

[](#filtermanagerregister)

Registers the filters (renders the dropdowns and modifies the query).

---

🛡 Security
----------

[](#-security)

- All incoming request data is sanitized (`sanitize_text_field`, `wp_unslash`)
- All HTML output is escaped (`esc_attr`, `esc_html`)
- No unsafe direct database queries (only safe `$wpdb->prepare` when auto-discovering meta values)

---

📄 License
---------

[](#-license)

MIT License. See `LICENSE` file for details.

---

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance70

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

8

Last Release

174d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79f94d2a6bb8178579ccfea14633d715487cdd10dc594b45c46a5dfb4b222eb0?d=identicon)[JorenRothman](/maintainers/JorenRothman)

---

Top Contributors

[![JorenRothman](https://avatars.githubusercontent.com/u/11407494?v=4)](https://github.com/JorenRothman "JorenRothman (9 commits)")

### Embed Badge

![Health badge](/badges/jorenrothman-wp-admin-filters/health.svg)

```
[![Health](https://phpackages.com/badges/jorenrothman-wp-admin-filters/health.svg)](https://phpackages.com/packages/jorenrothman-wp-admin-filters)
```

###  Alternatives

[jeroennoten/laravel-adminlte

Easy AdminLTE integration with Laravel

4.0k4.8M43](/packages/jeroennoten-laravel-adminlte)[dmstr/yii2-adminlte-asset

AdminLTE backend theme asset bundle for Yii 2.0 Framework

1.1k1.8M67](/packages/dmstr-yii2-adminlte-asset)[dwij/laraadmin

LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like CRUD Generation, Module Manager, Media, Menus, Backups and much more

1.6k68.7k](/packages/dwij-laraadmin)[filament/spatie-laravel-media-library-plugin

Filament support for `spatie/laravel-medialibrary`.

1764.8M125](/packages/filament-spatie-laravel-media-library-plugin)[bezhansalleh/filament-exceptions

A Simple &amp; Beautiful Pluggable Exception Viewer for FilamentPHP's Admin Panel

193195.9k13](/packages/bezhansalleh-filament-exceptions)[filament/infolists

Easily add beautiful read-only infolists to any Livewire component.

1220.8M36](/packages/filament-infolists)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
