Filter hook 'get_the_excerpt'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php at line 868

View Source

get_the_excerpt

Filter Hook
Description
Prepares a single attachment output for response.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php View on GitHub
Hook Type Filter
Line Number 868

Hook Parameters

Type Name Description
WP_Post $item Attachment object.
WP_REST_Request $request Request object.

Usage Examples

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

function my_custom_filter($item, $request) {
    // Your custom filtering logic here
    return $item;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php:868 - How this hook is used in WordPress core
<?php
 863  			);
 864  		}
 865  
 866  		if ( in_array( 'caption', $fields, true ) ) {
 867  			/** This filter is documented in wp-includes/post-template.php */
 868  			$caption = apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
 869  
 870  			/** This filter is documented in wp-includes/post-template.php */
 871  			$caption = apply_filters( 'the_excerpt', $caption );
 872  
 873  			$data['caption'] = array(

PHP Documentation

<?php
/**
	 * Prepares a single attachment output for response.
	 *
	 * @since 4.7.0
	 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
	 *
	 * @param WP_Post         $item    Attachment object.
	 * @param WP_REST_Request $request Request object.
	 * @return WP_REST_Response Response object.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
Related Hooks

Related hooks will be displayed here in future updates.