Remove facet value
-
Hello!
I either need to remove a facet value from being indexed, or a way to filter it on the front end from never displaying. It is 3 internal categories used but they should never be displayed.
I have made many attempts on the following code:
// EXCLUDE TERM FROM BEING INDEXED function custom_should_index_term( $should_index, $item ) { $terms_to_exclude = array( 63983, 63903, 63749 ); error_log( print_r( $terms_to_exclude, true ) ); error_log( print_r( $item, true ) ); if ( false === $should_index ) { return $should_index; error_log( "term was false before check" ); } if ( $item->post_type !== 'product' ) { return $should_index; error_log( "post type is not product" ); } $post_term_ids = wp_get_post_terms( $item->ID, 'product_cat', array("fields" => "ids") ); $remaining_term_ids = array_diff( $post_term_ids, $terms_to_exclude ); if ( count( $remaining_term_ids ) === 0 ) { return false; error_log( "Post type is product and term was found in array" ); error_log( print_r( $post_term_ids, true ) ); error_log( print_r( $remaining_term_ids, true ) ); } return $should_index; } add_filter('algolia_should_index_term', 'custom_should_index_term', 10, 2);
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Remove facet value’ is closed to new replies.