Skip to content

Instantly share code, notes, and snippets.

@DavidCramer
Created March 3, 2017 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidCramer/ab5bbd7087343124fd4d326109b6e644 to your computer and use it in GitHub Desktop.
Save DavidCramer/ab5bbd7087343124fd4d326109b6e644 to your computer and use it in GitHub Desktop.
exclude indexing if term is present
<?php
// add the below code to your child themes functions.php file.
function fwps_terms_exclude_index( $params ) {
// add your terms in here
$terms = array(
'expluded-term',
'anotehr-expluded'
);
/// set the name of your facet
if ( 'price' == $params['facet_name'] ) {
// can change the product_cat to any term to check
if( has_term( $terms, 'product_cat', $params['post_id'] ) ){
return false;
}
}
return $params;
};
add_filter( 'facetwp_index_row', 'fwps_terms_exclude_index' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment