【发布时间】:2017-09-12 19:15:41
【问题描述】:
1) 我试图将某些分类法排除在 Algolia 的索引之外。我无法完成这项工作。这是我的代码:
function exclude_taxonomy( $should_index_category, WP_Post $post )
{
// Add all post types you don't want to make searchable.
$excluded_event_categories = array(
'post_type' => 'events',
'tax_query' => array(
array(
'taxonomy' => 'events_category',
'field' => 'slug',
'terms' => 'xclude',
)
),
);
if ( false === $should_index_category ) {
return false;
}
return ! in_array( $post->taxonomy, $excluded_event_categories, true );
}
// Hook into Algolia to manipulate the post that should be indexed.
add_filter( 'algolia_should_index_searchable_post', 'exclude_taxonomy', 10, 2 );
2) 我将如何使用多种分类法来做到这一点。所以我有第二个:
'tax_query' => array(
array(
'taxonomy' => 'events_status',
'field' => 'slug',
'terms' => 'archive',
)
),
谢谢。
【问题讨论】: