facetwp schedule indexer

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

/** needs to be availble to cron to run **/
function fwp_single_index( $id ) {
FWP()->indexer->index( $id );
}
add_action( ‘fwp_single_index’, ‘fwp_single_index’ );

/** place in whatever function you want to initiate indexing, ex. after running an import **/
wp_schedule_single_event( time(), ‘fwp_single_index’, array( $post_id ) );

/** make sure your cron is running, some hosts have atypical setups for running cron and some turn it off on
** staging/development sites,
** https://wordpress.org/plugins/wp-crontrol/ can help debug cron issues
**/
{{/gist}}