Skip to content

Instantly share code, notes, and snippets.

@wpweb101
Last active June 8, 2016 14:18
Show Gist options
  • Save wpweb101/2e66fec61c31e2d04a1932ad93713c83 to your computer and use it in GitHub Desktop.
Save wpweb101/2e66fec61c31e2d04a1932ad93713c83 to your computer and use it in GitHub Desktop.
Facetwp Re-indexing EDD - Frontend Submissions checkbox values
<?php
add_filter( 'facetwp_index_row', 'wwce_facetwp_index_row' );
function wwce_facetwp_index_row( $params ) {
global $wpdb;
if ( 'genre' == $params['facet_name'] || 'instruments' == $params['facet_name'] || 'mood' == $params['facet_name'] ) {
$values = $params['facet_display_value'];
foreach ( $values as $val ) {
$wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->prefix}facetwp_index
(post_id, facet_name, facet_source, facet_value, facet_display_value) VALUES (%d, %s, %s, %s, %s)",
$params['post_id'],
$params['facet_name'],
$params['facet_source'],
$val,
$val
) );
}
// skip the default indexing query
return false;
}
return $params;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment