get_the_terms

FUNCTION wp-includes\category-template.php (ligne 1278) github
Retrieves the terms of the taxonomy that are attached to the post.

Paramètres

Entrée :
$post, $taxonomy
Sortie :
@param int|WP_Post $post     Post ID or object.
@param string      $taxonomy Taxonomy name.
@return WP_Term[]|false|WP_Error Array of WP_Term objects on success, false if there are no terms

Utilisation

// Utilisation de la fonction get_the_terms
$result = get_the_terms($post, $taxonomy);

if ($result) {
    // Votre logique ici
}

Actualités

Chargement des actualités...