searchwp\source\post\attributes\meta
Depuis : 4.0.0
Table des matières
Manipuler les données des champs personnalisés (postmeta) avant leur indexation.
Voir aussi searchwp\source\post\attributes\meta\${meta_key} pour un champ personnalisé unique.
Paramètres
| Type | Paramètre | Défaut | Depuis | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Mixte | $meta_value |
Valeur du champ personnalisé (après avoir été traitée par searchwp\source\post\attributes\meta\${meta_key}) |
4.0.0 |
||||||||||||
| Tableau |
$args
|
4.0.0 |
|||||||||||||
Exemples
All hooks should be added to your custom SearchWP Customizations Plugin.
Ajouter du contenu supplémentaire au champ personnalisé
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 ); |

