2016-10-11 14 views
1

現在、私はAlgoliaのワードプレスのすべてのページにインデックスを作成しています。Аlgolia - Wordpress - インデックスから特定のページを除外する

アルゴリアで特定のページのインデックスを作成しないようにするにはどうすればよいでしょうか?除外される必要がある約20ページがあるはずです。あなたはIDによって特定の投稿を除外するために、次の何ができる

答えて

2

:もちろん

/** 
* @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); 

をあなたはまた、ポストタイプやカスタム属性のような他の値にあなたの決定を基づかことができます。

関連する問題