1
目前,我正在爲Algolia中的所有WordPress網頁編制索引。Аlgolia - WordPress - 排除索引中的某些網頁
在Algolia中排除某些頁面被索引的最佳方法是什麼?應該有大約20頁需要排除。
目前,我正在爲Algolia中的所有WordPress網頁編制索引。Аlgolia - WordPress - 排除索引中的某些網頁
在Algolia中排除某些頁面被索引的最佳方法是什麼?應該有大約20頁需要排除。
你可以做以下的ID,以排除某些職位:
/**
* @param bool $flag
* @param WP_Post $post
*
* @return bool
*/
function custom_should_index_post($flag, WP_Post $post) {
// TODO: Replace with your own post IDs to exclude.
$excluded_ids = array(20, 25);
if (in_array($post->ID, $excluded_ids)) {
return false;
}
return $flag;
}
add_filter('algolia_should_index_post', 'custom_should_index_post', 10, 2);
add_filter('algolia_should_index_searchable_post', 'custom_should_index_post', 10, 2);
當然,你也可以的基礎上,如職位類型或自定義屬性的任何其他值決定。