<?php
/**
* Posts have a "CPU" post object field (ACF)
* CPUs have a "frequency" and "cores" field
*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
$name = $params['facet_name'];
$cpu_id = (int) $params['facet_value'];
if ( 'cpu_frequency' == $name ) {
$params['facet_value'] = get_field( 'frequency', $cpu_id );
$params['facet_display_value'] = get_field( 'frequency', $cpu_id );
}
elseif ( 'cpu_cores' == $name ) {
$params['facet_value'] = get_field( 'cores', $cpu_id );
$params['facet_display_value'] = get_field( 'cores', $cpu_id );
}
return $params;
}, 10, 2 );