X Features Cars Demo Power Plants Demo State Parks Demo Site Showcase Docs Tutorials Add-ons Buy



Dynamically register new facets.



The following example will add a new search facet.

add_filter( 'facetwp_facets', function( $facets ) {
    $facets[] = array(
        'label' => 'My Search',
        'name' => 'my_search',
        'type' => 'search',
        'search_engine' => '',
        'placeholder' => 'Enter keywords',
    return $facets;

We’re simply adding a new element to the $facets array. Every facet has a label, name, and type property (and most also have source).

Available settings

To see a facet type’s available settings, create a new facet and save it. Refresh, the page, then go into the Settings tab and export it. Paste the export code into http://jsonviewer.stack.hu/ to show the settings visually.

How it uses the admin UI

When a facet is registered programmatically, it’ll appear in the admin UI.


A notice will appear for code-based facets. To modify the facet, click the Unlock button.

When unlocked, FacetWP will save the facet’s settings in the database. If a facet exists in both code and the database, the database version will take precedence.

To switch back to the code-based settings, simply delete the facet from the admin UI.  On next refresh, the facet will re-appear in the admin UI (along with the notice).

See Also

How to Register Facets Programmatically

Facet Configuration