Action hook 'add_attachment'

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

View Source

add_attachment

Action Hook
Description
Fires once an attachment has been added.

Hook Information

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

Hook Parameters

Type Name Description
int $post_id Attachment ID.

Usage Examples

Basic Usage
<?php
// Hook into add_attachment
add_action('add_attachment', 'my_custom_function', 10, 1);

function my_custom_function($post_id) {
    // Your custom code here
}

Source Code Context

wp-includes/post.php:5033 - How this hook is used in WordPress core
<?php
5028  			 *
5029  			 * @since 2.0.0
5030  			 *
5031  			 * @param int $post_id Attachment ID.
5032  			 */
5033  			do_action( 'add_attachment', $post_id );
5034  		}
5035  
5036  		return $post_id;
5037  	}
5038  

PHP Documentation

<?php
/**
			 * Fires once an attachment has been added.
			 *
			 * @since 2.0.0
			 *
			 * @param int $post_id Attachment ID.
			 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.