SearchWP Documentation

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

searchwp\source\attribute\options

4.0.0以降

ソースの属性オプションを変更します。

パラメータ

タイプ パラメータ デフォルト 提供開始
配列 $options 定義済み属性オプション 4.0.0
配列 $args
キー タイプ
ソース 文字列 ソース名
属性 ストリ 属性名
検索 文字列 検索文字列(検索中の場合)
含める 配列 オプションのサブセットに制限する
4.0.0

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

'追加'メタデータ属性オプションを追加

<?php
// Add 'extra' metadata Attribute Options in SearchWP.
add_filter( 'searchwp\source\attribute\options', function( $options, $args ){
if( $args['attribute'] !== 'meta' ){
return $options;
}
$these_keys = [ 'my_custom_key' ];
foreach( $these_keys as $this_key ){
// Add this field if it's not added already.
if( ! in_array(
$this_key,
array_map( function( $option ){ return $option->get_value(); }, $options )
) ){
// Each option must be a \SearchWP\Option.
$options[] = new \SearchWP\Option( $this_key, 'Extra Metadata: ' . $this_key );
}
}
return $options;
}, 10, 2 );

このコードの使用方法