Last active
September 19, 2016 23:46
-
-
Save mgibbs189/4a8e5c0e018e257eceb1d057477b576f to your computer and use it in GitHub Desktop.
FacetWP - using the facetwp_indexer_post_facet filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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