SearchWP Documentation

インストールガイドを表示したり、ナレッジベースを参照したり、SearchWPの多くのフックについて確認したりできます。

searchwp\source\post\attributes\taxonomy\terms

4.0.0以降

インデックス作成前に投稿のタクソノミ用語を操作します。タクソノミーがエンジンに含まれている場合にのみ適用されます。

関連項目 searchwp\source\post\attributes\taxonomy\term 個々の用語をフィルタリングします。

パラメータ

タイプ パラメータ デフォルト 提供開始
WP_Term[] $terms タクソノミ用語オブジェクト 4.0.0
配列 $args
キー タイプ
taxonomy 文字列 タクソノミー名
post_id 整数 投稿ID
post_type 文字列 投稿タイプ
4.0.0

All hooks should be added to your custom SearchWP Customizations Plugin.

特定のカテゴリを投稿と一緒にインデックスしないようにする

インデックス作成時に未分類カテゴリ用語をインデックスしないようにします。

<?php
// Prevent specific Category from being indexed with posts in SearchWP.
add_filter( 'searchwp\source\post\attributes\taxonomy\terms', function( $terms, $args ) {
// Do not index the 'Uncategorized' term.
return array_filter( $terms, function( $term ) {
return 'Uncategorized' !== $term->name;
} );
}, 20, 2 );

このコードの使用方法