SearchWP Documentation

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

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
キー タイプ
post_id 整数 投稿ID
meta_key 文字列 カスタムフィールドのキー
meta_value 混合 カスタムフィールドの値
4.0.0

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

カスタムフィールドに追加コンテンツを追加

<?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 );

このコードの使用方法