get_terms

FUNCTION wp-includes\taxonomy.php (ligne 1264) github
Retrieves the terms in a given taxonomy or list of taxonomies. You can fully inject any customizations to the query before it is sent, as well as control the output with a filter. The return type varies depending on the value passed to `$args['fields']`. See WP_Term_Query::get_terms() for details. In all cases, a `WP_Error` object will be returned if an invalid taxonomy is requested. The {@see 'get_terms'} filter will be called when the cache has the term and will pass the found term along with the array of $taxonomies and array of $args. This filter is also called before the array of terms is passed and will pass the array of terms, along with the $taxonomies and $args. The {@see 'list_terms_exclusions'} filter passes the compiled exclusions along with the $args. The {@see 'get_terms_orderby'} filter passes the `ORDER BY` clause for the query along with the $args array. Taxonomy or an array of taxonomies should be passed via the 'taxonomy' argument in the `$args` array:     $terms = get_terms( array(         'taxonomy'   => 'post_tag',         'hide_empty' => false,     ) ); Prior to 4.5.0, taxonomy was passed as the first parameter of `get_terms()`. {@internal The `$deprecated` parameter is parsed for backward compatibility only.}

Paramètres

Entrée :
$args = array(
Sortie :
@param array|string $args       Optional. Array or string of arguments. See WP_Term_Query::__construct()
@param array|string $deprecated Optional. Argument array, when using the legacy function parameter format.
@return WP_Term[]|int[]|string[]|string|WP_Error Array of terms, a count thereof as a numeric string,

Utilisation

// Utilisation de la fonction get_terms
$result = get_terms($args = array();

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

Actualités

Chargement des actualités...