SearchWP Documentation

Consultez le guide d’installation, parcourez la base de connaissances, découvrez les nombreux hooks de SearchWP

searchwp\source\post\attributes\taxonomy\terms

Depuis : 4.0.0

Table des matières

Manipuler les termes de taxonomie d'un article avant l'indexation. Ne s'applique que lorsque la taxonomie a été incluse dans un moteur.

Voir aussi searchwp\source\post\attributes\taxonomy\term pour filtrer les termes individuels.

Paramètres

Type Paramètre Défaut Depuis
WP_Term[] $terms Objets de terme de taxonomie 4.0.0
Tableau $args
Clé Type Valeur
taxonomy Chaîne Nom de la taxonomie
post_id Entier ID de l'article
post_type Chaîne Type d'article
4.0.0

Exemples

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

Empêcher une catégorie spécifique d'être indexée avec les articles

Ne pas indexer le terme de catégorie Non classé lors de l'indexation.

<?php
// Prevent specific Category from being indexed with posts in SearchWP.
add_filter( 'searchwp\source\post\attributes\taxonomy\terms', function( $terms, $args ) {
// Do not index the 'Uncategorized' term.
return array_filter( $terms, function( $term ) {
return 'Uncategorized' !== $term->name;
} );
}, 20, 2 );

Comment utiliser ce code