Filter hook 'wp_get_attachment_caption'

in WP Core File wp-includes/post.php at line 6978

View Source

wp_get_attachment_caption

Filter Hook
Description
Filters the attachment caption.

Hook Information

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

Hook Parameters

Type Name Description
string $caption Caption for the given attachment.
int $post_id Attachment ID.

Usage Examples

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

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

Source Code Context

wp-includes/post.php:6978 - How this hook is used in WordPress core
<?php
6973  	 * @since 4.6.0
6974  	 *
6975  	 * @param string $caption Caption for the given attachment.
6976  	 * @param int    $post_id Attachment ID.
6977  	 */
6978  	return apply_filters( 'wp_get_attachment_caption', $caption, $post->ID );
6979  }
6980  
6981  /**
6982   * Retrieves URL for an attachment thumbnail.
6983   *

PHP Documentation

<?php
/**
	 * Filters the attachment caption.
	 *
	 * @since 4.6.0
	 *
	 * @param string $caption Caption for the given attachment.
	 * @param int    $post_id Attachment ID.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.