Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active September 19, 2016 23:46
Show Gist options
  • Save mgibbs189/4a8e5c0e018e257eceb1d057477b576f to your computer and use it in GitHub Desktop.
Save mgibbs189/4a8e5c0e018e257eceb1d057477b576f to your computer and use it in GitHub Desktop.
FacetWP - using the facetwp_indexer_post_facet filter
<?php
function lh_fwp_index_coming_soon_facet( $return, $params ) {
$facet_params = $params['defaults'];
if ( 'cf/edd_coming_soon' == $facet_params['facet_source'] ) {
$value = get_post_meta( $facet_params['post_id'], 'edd_coming_soon', true );
$value = empty( $value ) ? 'Available' : 'Coming Soon';
$facet_params['facet_value'] = $value;
$facet_params['facet_display_value'] = $value;
FWP()->indexer->index_row( $facet_params );
return true; // we're done indexing this facet
}
return $return;
}
add_filter( 'facetwp_indexer_post_facet', 'lh_fwp_index_coming_soon_facet', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment