searchwp\source\post\attributes\taxonomy\terms
4.0.0以降
インデックス作成前に投稿のタクソノミ用語を操作します。タクソノミーがエンジンに含まれている場合にのみ適用されます。
関連項目 searchwp\source\post\attributes\taxonomy\term 個々の用語をフィルタリングします。
パラメータ
| タイプ | パラメータ | デフォルト | 提供開始 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| WP_Term[] | $terms |
タクソノミ用語オブジェクト | 4.0.0 |
||||||||||||
| 配列 |
$args
|
4.0.0 |
|||||||||||||
例
All hooks should be added to your custom SearchWP Customizations Plugin.
特定のカテゴリを投稿と一緒にインデックスしないようにする
インデックス作成時に未分類カテゴリ用語をインデックスしないようにします。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 ); |

