facetwp_indexer_is_enabled
Overview
This hook disables FacetWP’s automatic (re-)indexing process.
With this hook in place, re-indexing will not automatically happen when you edit and save posts, but only when you press the “Re-index” button, or when you trigger the indexer programmatically, with PHP, WP-CLI/server cron or with WP-Cron.
Besides in combination with WP-CLI or WP-Cron indexing cron schedules, this hook can also be useful if you want to (temporarily) pause automatic indexing when importing content, or if you want to disable automatic indexing for certain types of content.
Parameters
- $is_enabled | boolean | Whether FacetWP’s automtic indexer is enabled
Disable automatic indexing
Add the following code to your (child) theme’s functions.php to entirely disable automatic indexing:
add_filter( 'facetwp_indexer_is_enabled', '__return_false' );
Conditionally disable automatic indexing
The following example disables automatic re-indexing for Advanced Custom Fields field groups:
<?php
add_filter( 'facetwp_indexer_is_enabled', function( $enabled ) {
if ( isset( $_POST['action'] ) && 'editpost' == $_POST['action'] &&
isset( $_POST['post_type'] ) && 'acf-field-group' == $_POST['post_type'] ) {
return false;
}
return $enabled;
});