我有algolia搜索工作在我的网站上,但在后端它也索引一个永远不应被索引的帖子类型(因为它包含私人信息).
在某处我可以说"NEVER index {post_type}"吗?
如果您正在谈论Algolia for WordPress插件,您肯定可以定义一个函数/钩子来决定是否应该为一个帖子类型编制索引.
比如你可以写:
<?php
/**
* @param bool $should_index
* @param WP_Post $post
*
* @return bool
*/
function exclude_post_types( $should_index, WP_Post $post )
{
if ( false === $should_index ) {
return false;
}
// Add all post types you don't want to make searchable.
$excluded_post_types = array( 'myprivatetype' );
return ! in_array( $post->post_type, $excluded_post_types, true );
}
// Hook into Algolia to manipulate the post that should be indexed.
add_filter( 'algolia_should_index_searchable_post', 'exclude_post_types', 10, 2 );
Run Code Online (Sandbox Code Playgroud)
您可以阅读更多信息:https://community.algolia.com/wordpress/indexing-flow.html#indexing-decision
| 归档时间: |
|
| 查看次数: |
93 次 |
| 最近记录: |