searchwp\source\attribute\label
4.0.0以降
ソース属性ラベルをカスタマイズ
パラメータ
| タイプ | パラメータ | デフォルト | 提供開始 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 文字列 | $label |
定義済みラベル | 4.0.0 |
|||||||||
| 配列 |
$args
|
4.0.0 |
||||||||||
例
すべてのフックはカスタムのSearchWP カスタマイズプラグインに追加する必要があります。
製品カスタム投稿タイプ用のコメント属性ラベルをカスタマイズ
多くのEコマースプラグイン(例:WooCommerce)は、製品レビューを保存するためにコメントを使用しています。このスニペットは、コメントのラベルをレビューに変更します。
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 Comments Attribute label for Products custom post type in SearchWP. | |
| add_filter( 'searchwp\source\attribute\label', function( $label ) { | |
| if ( 'post.product' === $args['source'] && 'comments' === $args['attribute'] ) { | |
| return 'Reviews'; | |
| } else { | |
| return $label; | |
| } | |
| }, 20, 2 ); |

