The add_attachment
action is fired when the wp_insert_attachment()
function is called to add an item to the media library. Images are added to posts after going into the media library first. Even when adding via the post editor, items are added to the library with wp_insert_attachment()
then to the post.
add_action( 'add_attachment', function( $post_ID ) {
// Do Stuff
});
This will not allow you to number items by post, only by instance in the media library. Whether that works for your purposes, I cannot answer.
https://codex.wordpress.org/Plugin_API/Action_Reference/add_attachment
Related Posts:
- WP Rest API – Upload media without saving attachment post
- Add a header before fields added with the attachment_fields_to_edit() filter
- How to add custom media library mime icons?
- How many filter/action hooks are healthy?
- Filter specific shortcode output?
- Earliest hook to reliably get $post/$posts
- What does (10, 2) mean when used with add_filter
- Clarification on filters and hooks
- Valid characters for actions, hooks and filters
- How to hook into unregistering a widget instance?
- How to check if a hook is hooked or not?
- Passing Additional Parameters to add_filter Callable
- Modify WordPress Rest Api Request/Response
- How to add some custom HTML into wordpress admin bar?
- Custom theme hooks / filters – passing arguments
- How to disable all WordPress emails modularly and programatically?
- How to hook wp_list_pages?
- How to use the_excerpt in a filter hook?
- Hook into admin post list page
- Change text of Description in Image Library
- Load different template file when condition met?
- Am I using the right hook for removing quicktags on the admin TinyMCE?
- About Hooks and Filters
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- Filter all html output
- How to trigger the core WPLANG to make automatically set a language when the theme is activated? [duplicate]
- Too many actions/filters!
- How to get list of all hooks of current theme / plugin?
- Why anything done on comments_array hook gets reset?
- add_filter() function misunderstanding
- Is it possible to track down Actions and Filters?
- add filter login_redirect does not contain original requested redirect
- get_header and hook avoid normal call
- How to add numeric slug for child page in WordPress 5.9?
- Can the wp_filter object hold multiple values with the same key
- apply_filters/do_action tag characters limit
- How to change the order of HTML output of a core block?
- Filter taxonomy admin pagination
- How to modify core when there is no hook?
- WP action/filter to modify title before header output and article output?
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- Post Content, Special Characters and Filters
- How to filter for user registration, be able to throw error message
- Gutenberg – Add align controls to a custom block
- How to remove action with slashes and arrows?
- Better extend a class or use add filter/action hooks?
- How to filter the image embed code based on link type
- Add default user field to WooCommerce checkout [closed]
- Changing WordPress core without hacking core
- Customize title, description and focused keyword [closed]
- Plugin options, presets and filters : can you help me improve my workflow?
- how to customize rss feed tags using hooks?
- Filtering the post list in the admin area
- Woocommerce “added to cart” message on main(home) page
- How to check if a protected hook is hooked?
- Wrapping my head around add_filter
- Gutenberg Block – Post Featured Image Filter Hook
- Modify message displayed on post save
- Filter media upload attachment meta
- Change custom post type GUID in RSS
- Pass debug_backtrace() in WordPress filter
- filter hook to load a different post/page on current post/page
- Remove actions/filters that are set with create_function()
- Redirect to woocommerce checkout after adding to cart – item already in cart
- How to access page variable inside action hook
- I need to hook and change language of facebook sdk
- Use has_filter on comment_post
- How To Get Search Term and Use in Function
- Renaming wordpress login and get new password button
- Hook in a sidebar widget and add some markup
- BuddyPress – A hook available to hide custom born date on public profile view?
- Same URL for portfolio and for a page creates 404 error. Is there any filter that i can use for a child page?
- ‘manage_users_custom_column’ is a filter, but ‘manage_posts_custom_column’ is an action. Why?
- How do I add a line break to a string that is output by PHP?
- Scanning for custom embed and prefetching
- Filter widget_posts_args not working
- Filter the title to only affect the_title() template function
- Remove and replace woocommerce add to cart button [closed]
- style_loader_tag not changing stylesheet to preload
- How can I filter the comment action links so that I can display the actions links based on user capabilities?
- Hook to change the site URL
- Modify WordPress Page Title ()
- How can I limit access to uploaded media depending on the logged in user’s user role?
- Right filter for rewriting page statuscode
- Add Index to Item in WordPress Gallery
- Re-order search results with posts_orderby filter and post meta value
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Adding user filter – Not updating data in URL
- How to check which submission button was clicked?
- Converting restricted html in comments to bbcode
- Why none of xmlrpc filters work
- Post Type Upload Directory – {post_type}_upload_dir filter
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- Which hook should be used in this case?
- Getting entry ID from frm_email_message filter in formidable
- WooCommerce comments_template Filter Not Firing
- Auto append text after the title?
- How to use apply_filters(‘get_calendar’) to change get_calendar() output?
- Can you call a filter hook by “add_action”?
- Passing value from one hook to another