Algolia - WordPress,仅在一个 CPT(索引)中显示特定类别
Algolia - WordPress, Only show certain category within one CPT (index)
我已经安装了 Algolia 插件,根据文档创建了模板并添加了我正在调用给定 CPT 索引中的所有项目。是否有任何设置允许我仅从某些 category/term 中提取?
var search = instantsearch({
appId: 'XXXXXXXXXX',
apiKey: 'xxxxxxxxxxxxxxxxxxxxxx',
索引名称:'rb_posts_it-blog',
url同步:真
});
我在文档中的任何地方都找不到这个。
条款默认标记为 attributesForFaceting
,这意味着您可以轻松地对其进行过滤。
下面是一个示例,说明您将如何根据类别进行过滤。根据您使用的小部件类型,您需要删除不需要的过滤器:
var search = instantsearch({
[...],
searchParameters: {
hierarchicalFacetsRefinements: { // menu is implemented as a hierarchicalFacetsRefinements
categories: ['Cell Phones']
},
facetsRefinements: {
isPremium: [true]
},
disjunctiveFacetsRefinements: {
brand: ['Samsung', 'Apple']
},
// Add to "facets" all attributes for which you
// do NOT have a widget defined
facets: ['isPremium']
},
});
// Below is just a common widget configuration, to show
// how it interacts with the above searchParameters
search.addWidget(
instantsearch.widgets.menu({
[...],
attributeName: 'categories'
})
);
search.addWidget(
instantsearch.widgets.refinementList({
attributeName: 'brand',
operator: 'or'
})
);
有关自定义默认过滤器的完整文档可在此处获取:https://community.algolia.com/instantsearch.js/documentation/#default-filters
我已经安装了 Algolia 插件,根据文档创建了模板并添加了我正在调用给定 CPT 索引中的所有项目。是否有任何设置允许我仅从某些 category/term 中提取?
var search = instantsearch({ appId: 'XXXXXXXXXX', apiKey: 'xxxxxxxxxxxxxxxxxxxxxx', 索引名称:'rb_posts_it-blog', url同步:真 });
我在文档中的任何地方都找不到这个。
条款默认标记为 attributesForFaceting
,这意味着您可以轻松地对其进行过滤。
下面是一个示例,说明您将如何根据类别进行过滤。根据您使用的小部件类型,您需要删除不需要的过滤器:
var search = instantsearch({
[...],
searchParameters: {
hierarchicalFacetsRefinements: { // menu is implemented as a hierarchicalFacetsRefinements
categories: ['Cell Phones']
},
facetsRefinements: {
isPremium: [true]
},
disjunctiveFacetsRefinements: {
brand: ['Samsung', 'Apple']
},
// Add to "facets" all attributes for which you
// do NOT have a widget defined
facets: ['isPremium']
},
});
// Below is just a common widget configuration, to show
// how it interacts with the above searchParameters
search.addWidget(
instantsearch.widgets.menu({
[...],
attributeName: 'categories'
})
);
search.addWidget(
instantsearch.widgets.refinementList({
attributeName: 'brand',
operator: 'or'
})
);
有关自定义默认过滤器的完整文档可在此处获取:https://community.algolia.com/instantsearch.js/documentation/#default-filters