searchwp\source\post\attributes\meta
4.0.0以降
カスタムフィールド(postmeta)のデータをインデックス化する前に操作します。
単一のカスタムフィールドについては、searchwp\source\post\attributes\meta\${meta_key} を参照してください。
パラメータ
| タイプ | パラメータ | デフォルト | 提供開始 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 混合 | $meta_value |
カスタムフィールドの値(searchwp\source\post\attributes\meta\${meta_key} を実行した後) |
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 | |
| // Add additional content to Custom Field during indexing in SearchWP. | |
| add_filter( 'searchwp\source\post\attributes\meta', function( $meta_value, $args ) { | |
| if ( 'my_custom_field_key' !== $args['meta_key'] ) { | |
| return $meta_value; | |
| } | |
| // Add 'coffee' to Custom Field value to make it searchable. | |
| return $meta_value[0] . ' coffee'; | |
| }, 20, 2 ); |

