Filter hook 'get_terms'

in WP Core File wp-includes/taxonomy.php at line 1379

View Source

get_terms

Filter Hook
Description
Filters the found terms.

Hook Information

File Location wp-includes/taxonomy.php View on GitHub
Hook Type Filter
Line Number 1379

Hook Parameters

Type Name Description
array $terms Array of found terms.
array|null $taxonomies An array of taxonomies if known.
array $args An array of get_terms() arguments.
WP_Term_Query $term_query The WP_Term_Query object.

Usage Examples

Basic Usage
<?php
// Hook into get_terms
add_filter('get_terms', 'my_custom_filter', 10, 4);

function my_custom_filter($terms, $taxonomies, $args, $term_query) {
    // Your custom filtering logic here
    return $terms;
}

Source Code Context

wp-includes/taxonomy.php:1379 - How this hook is used in WordPress core
<?php
1374  	 * @param array         $terms      Array of found terms.
1375  	 * @param array|null    $taxonomies An array of taxonomies if known.
1376  	 * @param array         $args       An array of get_terms() arguments.
1377  	 * @param WP_Term_Query $term_query The WP_Term_Query object.
1378  	 */
1379  	return apply_filters( 'get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query );
1380  }
1381  
1382  /**
1383   * Adds metadata to a term.
1384   *

PHP Documentation

<?php
/**
	 * Filters the found terms.
	 *
	 * @since 2.3.0
	 * @since 4.6.0 Added the `$term_query` parameter.
	 *
	 * @param array         $terms      Array of found terms.
	 * @param array|null    $taxonomies An array of taxonomies if known.
	 * @param array         $args       An array of get_terms() arguments.
	 * @param WP_Term_Query $term_query The WP_Term_Query object.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/taxonomy.php
Related Hooks

Related hooks will be displayed here in future updates.