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

facetwp_index_row

Overview

FacetWP uses a custom database table to store values for all facets. This filter lets you modify what gets saved to this table during the indexing process.

Parameters

// The keys correspond with columns in the `facetwp_index` table
$params = array(
    'post_id' => 123,
    'facet_name' => 'my_facet',
    'facet_source' => 'tax/category',
    'facet_value' => '45',
    'facet_display_value' => 'My Test Category',
    'term_id' => 0,
    'parent_id' => 0,
    'depth' => 0,
    'variation_id' => 0
);

Usage

// Save date in "Jan 1, 2014" format
add_filter( 'facetwp_index_row', function( $params, $class ) {
    if ( 'my_date' == $params['facet_name'] ) {
        $raw_value = $params['facet_value'];
        $params['facet_display_value'] = date( 'M j, Y', strtotime( $raw_value ) );
    }
    return $params;
}, 10, 2 );

Other Notes