Refers to FiboSearch Pro only

How to exclude certain attributes from the search scope?

The search attributes feature allows users to search all attributes. In some cases, you should exclude attributes that make no sense for the search process.

Where can you find the attribute names?

In WooCommerce, attributes are treated as custom taxonomies. To exclude a specific attribute, you must use its corresponding taxonomy name. WooCommerce adds the pa_ prefix to each attribute slug, creating a custom taxonomy. For instance, if the attribute slug is height, the taxonomy will be pa_height. To find the taxonomy for an attribute, go to ProductsAttributes, select the attribute, and check its URL. The taxonomy name will be included in the URL.

Custom snippet

/**
 * Attributes to exclude
 *
 * @return array
 */
function fibosearch_get_attributes_to_exclude() {
	return array(
		'pa_calipers', //Replace with yours!!!
		'pa_case-size' //Replace with yours!!!
	);
}

/**
 * Exclude attribute every time when the product is updated
 *
 * @return array
 */
add_filter( 'dgwt/wcas/product/attributes', function ( $attributes ) {
	foreach ( fibosearch_get_attributes_to_exclude() as $taxonomy ) {
		if ( array_key_exists( $taxonomy, $attributes ) ) {
			unset( $attributes[ $taxonomy ] );
		}
	}

	return $attributes;
} );

/**
 * Exclude attribute every time when the whole index process is running
 *
 * @return array
 */
add_filter( 'dgwt/wcas/attribute_taxonomies', function ( $taxonomies ) {
	foreach ( fibosearch_get_attributes_to_exclude() as $taxonomy ) {
		if ( ( $key = array_search( $taxonomy, $taxonomies ) ) !== false ) {
			unset( $taxonomies[ $key ] );
		}
	}

	return $taxonomies;
} );

Learn how to add this snippet to your WordPress.

After adding the code, remember to rebuild the search index:

Go to WooCommerceFiboSearchIndexer (tab) and rebuild the search index. Wait for this process to finish.