searchwp\source\post\attributes\content
4.0.0以降
投稿コンテンツをインデックスする前にカスタマイズします。
パラメータ
| タイプ | パラメータ | デフォルト | 提供開始 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 文字列 | $content |
インデックス作成する投稿コンテンツ | 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 post during indexing in SearchWP. | |
| add_filter( 'searchwp\source\post\attributes\content', function( $content, $args ) { | |
| if ( 48 !== $args['post']->ID ) { | |
| return $content; | |
| } | |
| // Add 'coffee" to the content for Page 48 so it can be searched. | |
| $content .= ' coffee'; | |
| return $content; | |
| }, 20, 2 ); |

