searchwp\source\post\attributes\taxonomy\term
4.0.0以降
インデックス作成前に投稿のタクソノミ用語を操作します。タクソノミーがエンジンに含まれている場合にのみ適用されます。
関連項目 searchwp\source\post\attributes\taxonomy\terms をクリックして、すべてのタームを一度にフィルタリングします。
パラメータ
| タイプ | パラメータ | デフォルト | 提供開始 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| \WP_Term | $term |
インデックス作成中のターム | 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 | |
| // Customize taxonomy term before it is indexed by SearchWP. | |
| add_filter( 'searchwp\source\post\attributes\taxonomy\term', function( $term, $args ) { | |
| // Add 'coffee' to specific term name so it is searchable. | |
| if ( 'My Custom Term' === $term->name ) { | |
| $term->name .= ' coffee'; | |
| } | |
| return $term; | |
| }, 20, 2 ); |

