PHPackages                             mrkoopie/wp\_ajaxfilter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mrkoopie/wp\_ajaxfilter

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

mrkoopie/wp\_ajaxfilter
=======================

Generate HTML forms and filter archive data in WordPress

v0.3.0(9y ago)141[5 issues](https://github.com/MrKoopie/WP_ajaxfilter/issues)PHP

Since Apr 8Pushed 9y ago1 watchersCompare

[ Source](https://github.com/MrKoopie/WP_ajaxfilter)[ Packagist](https://packagist.org/packages/mrkoopie/wp_ajaxfilter)[ RSS](/packages/mrkoopie-wp-ajaxfilter/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (12)Used By (0)

WP\_ajaxfilter
==============

[](#wp_ajaxfilter)

[![Total Downloads](https://camo.githubusercontent.com/9d32c6b27ab42f221d54c7e38d93989759ad3593fe4ea9e3f21606f253989904/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d726b6f6f7069652f77705f616a617866696c7465722e737667)](https://packagist.org/packages/mrkoopie/wp_ajaxfilter)[![Latest Stable Version](https://camo.githubusercontent.com/dfc738e2a01f6ec0ae055164a1b1cf0386504024fd19a58f5a1570b1ab66129a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d726b6f6f7069652f77705f616a617866696c7465722e737667)](https://packagist.org/packages/mrkoopie/wp_ajaxfilter)[![Build status](https://camo.githubusercontent.com/03d5bf24ec54ffac64d27bc3fc9c069727fed61462452969d0f64b7b41569369/68747470733a2f2f7472617669732d63692e6f72672f4d724b6f6f7069652f57505f616a617866696c7465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/MrKoopie/WP_ajaxfilter)

This package is developed to be a part of a WordPress theme or plugin. By installing this code you can add an advanced filter without writing every piece of HTML, PHP, javascript and CSS code. The package is still in development and may not

How to install
--------------

[](#how-to-install)

Run the following command:

```
composer require mrkoopie/wp_ajaxfilter
```

Add to your functions.php the following code:

```
function ajaxfilter($filter_id)
{
    if(!isset($GLOBALS['WP_ajaxfilter'][$filter_id]))
        $GLOBALS['WP_ajaxfilter'][$filter_id] = new MrKoopie/WP_ajaxfilter/generator($filter_id);

    return $GLOBALS['WP_ajaxfilter'][$filter_id];
}

require_once('vendor/autoload.php');
```

How to use the code in a theme
------------------------------

[](#how-to-use-the-code-in-a-theme)

The code is designed to have a controller inside your functions.php (or any file that is included in your functions.php) and a simple call in a template file.

```
# functions.php
/**
 * Here we configure the ajaxfilter with the form id your_filter_id.
 * This id should be unique and is used in the template to output
 * the filter and is used as a selector in jQuery.
 */
ajax_filter('your_filter_id')
    // Configure the input fields
    ->add_checkbox(__('Province'), 'taxonomy_province', 'optional_tech_name_province')

    // The jQuery script will make an ajax call, set the
    // template filter here. The filter will use
    // get_template_part('your_ajax_template'), so you
    // can use the same input method.
    ->set_ajax_template('your_ajax_template')

    // By running render, we activate the query filter
    // and create the ajax listener.
    ->render();

# template.php
/**
 * This command outputs the HTML form. Keep in mind that you have to put
 * a  somewere!
 */
ajax_filter('your_filter_id')->html();
```

###### add\_checkbox($label, $taxonomy\_id, $tech\_name )

[](#add_checkboxlabel-taxonomy_id-tech_name-)

$label is shown in the tag. $taxonomy\_id is the id of the taxonomy where the data is loaded of. $tech\_name This name is used for the technical field name (which is shown in every GET request).

##### set\_ajax\_template($template\_name)

[](#set_ajax_templatetemplate_name)

$template\_name is the name of your template inside your theme. This template is used to show the results of the filter.

##### render()

[](#render)

With this function the query filter is set and the ajax call is registered.

How to override the stubs
-------------------------

[](#how-to-override-the-stubs)

1. Create in your theme the directory overrides/wp\_ajaxfilter\_stubs/.
2. Create every stub file that you want to override there.

**The stubs are designed to be flexible and should allow you to create the correct styling. If you feel this is not the case, please make a pull request with an improved stub file.**

Todo
====

[](#todo)

Add support for:

- Comparison methods

###### TODO: add\_dropdown($label, $taxonomy\_id, $tech\_name )

[](#todo-add_dropdownlabel-taxonomy_id-tech_name-)

$label is shown in the tag. $taxonomy\_id is the id of the taxonomy where the data is loaded of. $tech\_name This name is used for the technical field name (which is shown in every GET request).

###### TODO: add\_radiobuttons($label, $taxonomy\_id, $tech\_name )

[](#todo-add_radiobuttonslabel-taxonomy_id-tech_name-)

$label is shown in the tag. $taxonomy\_id is the id of the taxonomy where the data is loaded of. $tech\_name This name is used for the technical field name (which is shown in every GET request).

###### TODO: add\_text($label, $field = 's', $tech\_name )

[](#todo-add_textlabel-field--s-tech_name-)

$label is shown in the tag. With $field you define the field where the filter applies to. Set this to s (default) to use the default WordPress search fields.

FAQ
===

[](#faq)

### Why is this not a plugin?

[](#why-is-this-not-a-plugin)

A plugin would require a GUI in the back-end, which is not provided by this package. This package is designed to be used within a theme or a plugin, to make the life of a developer easier.

### Why are you using Mockery for mocking?

[](#why-are-you-using-mockery-for-mocking)

The [developers](https://github.com/phpspec/prophecy/issues/44) of Prophecy did not include support for magic functions like \_\_call(). Although they do have a point, in this case we need to use \_\_call in order to mock WordPress functions without predefining every possible WordPress function.

Credits
=======

[](#credits)

Jasper Kums, Eenvoud Media B.V. - For providing feedback.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~10 days

Recently: every ~20 days

Total

9

Last Release

3648d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48f6009cc6459e5ccb495b790724a2645b7b5eb5f33bb2e6917f054c052da062?d=identicon)[dkoop](/maintainers/dkoop)

---

Top Contributors

[![MrKoopie](https://avatars.githubusercontent.com/u/3456873?v=4)](https://github.com/MrKoopie "MrKoopie (47 commits)")

---

Tags

wordpressajaxarchive filter

### Embed Badge

![Health badge](/badges/mrkoopie-wp-ajaxfilter/health.svg)

```
[![Health](https://phpackages.com/badges/mrkoopie-wp-ajaxfilter/health.svg)](https://phpackages.com/packages/mrkoopie-wp-ajaxfilter)
```

###  Alternatives

[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4753.9M23](/packages/coenjacobs-mozart)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[brianhenryie/strauss

Prefixes dependencies namespaces so they are unique to your plugin

186406.5k30](/packages/brianhenryie-strauss)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[oat-sa/generis

TAO generis library

10144.6k109](/packages/oat-sa-generis)

PHPackages © 2026

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