-
Notifications
You must be signed in to change notification settings - Fork 62
Im Trying To
If you need to control whether or not content is indexed, on a per-item basis, you can use the following filters. Each filter includes a boolean value for whether or not to index, as well as the current item object being considered. If a post, it'll be a WP_Post object, terms will receive a WP_Term object, and users will receive a WP_User object. You will want to return true if the item should still be indexed, or false if it should not be indexed.
Searchable/Instantsearch:
algolia_should_index_searchable_post
Autocomplete:
algolia_should_index_post
algolia_should_index_term
algolia_should_index_user
Even though Advanced Custom Fields is specific to Advanced Custom Fields, the code is largely the same even if you're not using ACF. You would need to change the examples from using get_field() to get_post_meta().
Make use of algolia_excluded_post_types filter to exclude specific post types. See example filter callback at Filter Hooks
You will need to intercept the found searchable post types and remove them from an array, instead of pushing the post type into an array. This is reverse from the available filter for Autocomplete.
function wds_algolia_exclude_searchable_post_types( $searchable_post_types ) {
$remove = [ 'movie', 'tv_show' ];
foreach( $searchable_post_types as $key => $type ) {
if ( in_array( $key, $remove ) ) {
unset( $searchable_post_types[ $key ] );
}
}
return $searchable_post_types;
}
add_filter( 'algolia_searchable_post_types', 'wds_algolia_exclude_searchable_post_types' );