FacetWP – automatically sync WPJM Reviews

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// Re-index when a comment’s status changes
add_action( ‘transition_comment_status’, function( $new_status, $old_status, $comment ) {
$post_id = $comment->comment_post_ID;
if ( ‘job_listing’ == get_post_type( $post_id ) ) {
FWP()->indexer->index( $post_id );
}
}, 12, 3 );

// Re-index when saving
add_action( ‘wpjmr_after_save_comment_review’, function( $comment_id ) {
$comment = get_comment( $comment_id );
FWP()->indexer->index( $comment->comment_post_ID );
}, 12 );

{{/gist}}