Filter hook 'get_the_terms'

in WP Core File wp-includes/category-template.php at line 1314

View Source

get_the_terms

Filter Hook
Description
Filters the list of terms attached to the given post.

Hook Information

File Location wp-includes/category-template.php View on GitHub
Hook Type Filter
Line Number 1314

Hook Parameters

Type Name Description
WP_Term[]|WP_Error $terms Array of attached terms, or WP_Error on failure.
int $post_id Post ID.
string $taxonomy Name of the taxonomy.

Usage Examples

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

function my_custom_filter($terms, $post_id, $taxonomy) {
    // Your custom filtering logic here
    return $terms;
}

Source Code Context

wp-includes/category-template.php:1314 - How this hook is used in WordPress core
<?php
1309  	 *
1310  	 * @param WP_Term[]|WP_Error $terms    Array of attached terms, or WP_Error on failure.
1311  	 * @param int                $post_id  Post ID.
1312  	 * @param string             $taxonomy Name of the taxonomy.
1313  	 */
1314  	$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
1315  
1316  	if ( empty( $terms ) ) {
1317  		return false;
1318  	}
1319  

PHP Documentation

<?php
/**
	 * Filters the list of terms attached to the given post.
	 *
	 * @since 3.1.0
	 *
	 * @param WP_Term[]|WP_Error $terms    Array of attached terms, or WP_Error on failure.
	 * @param int                $post_id  Post ID.
	 * @param string             $taxonomy Name of the taxonomy.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/category-template.php
Related Hooks

Related hooks will be displayed here in future updates.