You need to use before_delete_post action. As its already very late when delete_post action is run. WordPress un-attach all the attachments before running delete_post action. So when you run get_posts in your delete_attachment function there are no attachments found.
So you need to hook your function to before_delete_post.
add_action('before_delete_post','abc_delete_attachment');
Related Posts:
- Is there a action hook for the “Empty Trash” button?
- Function to execute when a post is moved to trash .
- add action only on post publish – not update
- How to validate XML-RPC post creation and cancel when needed?
- Create posts on user registration
- How to publish a post with empty title and empty content?
- How to add a “publish” link to the quick actions
- Action hook ‘wp’ firing twice… why?
- Count singular post views automatically
- Get the post_id of a new post
- Custom function for “Submit for Review” hook
- how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?
- How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
- the_posts filter been called multiple time
- Get post id in wordpress action?
- How can i do something after head like adding a hook for after head but before post
- How to run a function when post is edited or updated using publish post action?
- Create cron job without a plugin?
- How to generate numbers indistinguishable for the IDs of the posts
- Adding custom fields to bbpress reply form
- Adding buttons to Add New Post and Add New Page
- How to access $post from a callback function
- Set static page/post from another blog on same network
- Copy post to separate database with “add_action(….)”
- Call Web Services on post first publish
- How to check if single.php has already called the_post_thumbnail function
- What does WordPress do if I save a post without content/title? [duplicate]
- Divs appearing everywhere in post content
- Prevent posts with certain post_meta to be edited
- How to check in functions.php if there is data in a WP_Query?
- Update post meta within save_post action
- Automatically set post_parent value
- Exists filter or action that change Add New Post link?
- Actions to use when flushing cache (when posts are added / deleted / modified)
- Is there a way to know when a page has been updated and do some action only once?
- Run a function when a custom post is update?
- the wp_post_update isn’t working all the time
- Send email to user when I publish a new post
- Is update_post_meta used when save_post action hook is invoked?
- Count singular post views automatically
- How can i take all ids from untrash_post action?
- Grab meta data before post is saved
- Is it possible to completely replace a post with an action/filter?
- Hook To Get All Posts Deleted
- Action while post is being published
- Do anything on post_status change [duplicate]
- Modify upload directory to use post category slug in file path on multisite installation
- How to display by default only published posts/pages in the admin area?
- Is there an if statement that can determine if a post in the loop is the last post?
- WP_Query: Why is sticky post not first item in loop?
- Is there a way to disable the sticky posts feature?
- Can I load posts via Ajax?
- Filter posts by author and category simultaneously
- All WordPress scheduled posts are being published immediately
- WordPress Delete hook with wp_delete_post function?
- Undelete post (untrash)?
- Is there an action that is called when a post is restored from the trash?
- Double count view in archive.php
- Count search results in heading
- How to style the last post on the front page different than the others?
- Publish a Post on a Future Date Automtically
- Get mixed category random posts
- WordPress not opening posts with only numbers if permalink is post_name
- Decide user that can publish a post
- Thumbnail & Category link aside post
- My wordpress based site is publishing the same post twice
- How to make a sum of all posts displayed in a loop
- First x post with another template then the others
- add bootstrap post slider with tabs
- Show all posts shows a blank white page in WP 4.2.2 [closed]
- Get URL from all images in a post
- single post showing blank page in custom template
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Get total post from an author
- How to embed the content of one post into another site
- Prohibit saving a post without providing a title
- Limiting post list by taxonomy
- Standalone form does not post to the url when form fields are populated (otherwise it does)
- Will multiple category descriptions effect my search engine optimization?
- How to prevent to create same url of post, if the previous was deleted?
- ‘QTags.addButton: arg2 distorts the button rather than just shows
- WordPress Post 403 Error Based on Slug
- How to add first 3-4 post tags on WordPress Post Title
- WordPress React re-rendering to many times
- How to add class to specific navbar item when post parent category is in specific category
- How to get unmodified post content?
- Posts are not displaying on their category and tag page
- I need show posts by customer (Shortcode)
- Show custom post category for single post
- How to delete all posts with dead image urls?
- Get a list of categories that are related to posts
- Post Per Page For Portfolio
- How to modify specific parts of a post content in WordPress
- Loop through posts by each term and exclude duplicate posts assigned to several terms
- Change link to permalink inside post content
- Is possible to create a custom link that creates a post that’s already categorized?
- How to change link with broken link?
- Only show posts with image and the correct ammount of posts in loop
- Related posts by searching post tags of single post as terms
- How to make a local “scroll to ID” on post?