Skip to content

Instantly share code, notes, and snippets.

@rayrutjes
Created September 28, 2017 15:35
Show Gist options
  • Save rayrutjes/70eb29158234e893700c9c414b5dcdc4 to your computer and use it in GitHub Desktop.
Save rayrutjes/70eb29158234e893700c9c414b5dcdc4 to your computer and use it in GitHub Desktop.
Programmatic re-indexing index WordPress Algolia plugin
<?php
$algolia = Algolia_Plugin::get_instance();
$index = $algolia->get_index('posts_product');
$total_pages = $index->get_re_index_max_num_pages();
if ( $total_pages === 0 ) {
$index->re_index( 1 );
return;
}
$page = 1;
do {
$index->re_index( $page++ );
} while ( $page <= $total_pages );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment