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

How to Register Facets Programmatically

FacetWP supports registering facets in code using the facetwp_facets filter.


The following example will add a new search facet.

function mytheme_register_facets( $facets ) {
    $facets[] = array(
        'label' => 'My Search',
        'name' => 'my_search',
        'type' => 'search',
        'search_engine' => '',
        'placeholder' => 'Enter keywords',
    return $facets;
add_filter( 'facetwp_facets', 'mytheme_register_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).

To learn more about this filter and to see each facet type’s available settings, please visit the documentation page.