Using wp_delete_attachment( $attachmentid, true )
is only thing you need.
Passing true
as second argument, ($force_delete
see codex ) it:
- remove the thumbnail association with any post
- delete any taxonomy associated to attachment
- and of course remove all the files, also the autogenerated ones
So you do not need to also use delete_post_thumbnail()
.
Related Posts:
- How to get image title/alt attribute?
- How to Fix HTTP Error When Uploading Images?
- Delete original image – keep thumbnail?
- Set Featured Image Front Frontend Form
- media_sideload_image generates blank?
- How to change _wp_attachment_metadata specific value in SQL?
- Set (featured) thumbnail for post?
- How can I get a different image size, if all I have is the link?
- How to set an attachments parent post id in code?
- How do i show wordpress attachments from current post?
- Need clear explanation about medias/files/attchments
- Image still attached to post even after removing it as featured image
- Exclude featured image from attachment loop
- How to create resized versions of images added with wp_insert_attachment
- Show Multiple Size URL of one Featured Image/Thumbnail?
- Check if parent post is sticky on attachment page?
- How to attach images that I “insert from url” into the post?
- Moved server, and WP now uses original images for all thumb sizes?
- replace featured image from frontend
- Featured Image URL is Showing but not thumbnail
- Import Dummy Content and Post Thumbnails
- Get all images from posts with maximum number and without featured image
- Why not attaching images after impoting using wp cli
- Close featured image modal windows with JS
- Add class name to post thumbnail
- the_post_thumbnail responsive srcset not populating with custom image size
- Set custom name for generated thumbnails
- How to add multiple image sizes of the same size with add_image_size
- change set_post_thumbnail_size according to post type admin page
- Can’t extract and set SVG dimensions
- Getting Thumbnail Path rather than Image Tag
- How to crop thumbnail height to auto with set width
- Insert an image into a post by API
- How can I display my featured image correctly inside my single posts?
- Featured image upload finished hook
- Generate thumbnail for images with the same size as thumbnails
- Implementing Zurb’s Interchange Into WordPress
- how to test for attached image
- Display the first image from a post in RSS feed
- Filter For Featured Image
- add_image_size and add_filter(‘image_size_names_choose’, ‘my_custom_image_sizes’) not working with wordpress 3.5.2
- Custom post type thumbnail / Media Library WP_DEBUG notice [closed]
- How to scale up post thumbnails/featured image?
- Get Ancestor featured image
- Upload 3 different featured image sizes to WordPress
- Change size of featured image in Edit Post screen
- Thumbnail and Featured Image With Fixed Sizes?
- the_post_thumbnail ignores size parameter
- WordPress thumbnail settings change
- Using concatenate with WordPress Thumbnail
- Looking for Add Title Tag on Feature Images on WP
- Is it possible to nest get_previous_post()?
- Output post thumbnail (add class)
- How to set an equal image size for a Fallback Image as used for the Featured Image(dynamicly)
- How can I see where in my themes and plugins certain image sizes are used?
- Custom image size in the_content loop
- Display featured image file size, extension, filename, type, orientation?
- Video playing from featured image?
- get_the_post_thumbnail(‘thumbnail-name’) always returns empty string
- array set title and alt in the_post_thumbnail
- Get thumbnail image according to the screen
- Image Alignment on Featured Images
- Trying to show link “Use as featured image” from Attachment window from t31os script
- Use Featured Image of Post as Header Image
- Recent posts on homepage: different thumbnail based on logged in status and post category
- How to display featured image description and title?
- Images uploaded on frontend display correctly but not in media editor.
- get_post_thumbnail does not display thumbnail
- Make image full width
- WordPress 4.4 responsive sometimes doesn’t work
- get_the_post_thumbnail($post->ID, ‘thumbnail’); not working. How can I solve this?
- Getting featured image of particular size.
- Different thumbnails for index and article page
- Attachment Image using wrong src?
- On what point (hook) does the_/has_post_thumbnail() load?
- Thumbnails not being generated for PDF files
- Make 1st Slide of PowerPoint file to be the Post thumbnail preview image
- How to echo images Urls from a wordpress post, that are relally in the post
- Set featured image from auto generated video thumbnail url php
- Use Post Title as alt text for Featured Image
- How to cropped thumbnail image without distorting it?
- WordPress default srcset with hard crop
- wp_get_attachment_metadata()[‘image_meta’] fetch WP metadata or EXIF?
- White Blank screen and issue to get thumbnail in
- Set Featured Image Based on Custom Field
- Using lower resolution/size images for thumbnails on posts index
- How to have featured image show in standard RSS Widget
- Link from Thumbnail to Post not working
- Featured Image metabox (postimagediv) doesn’t appears when it should
- Thumbnails not showing in blog
- Featured Image inserted through custom query, does not show up
- How to import linked images and make them featured -> automagically
- Thumbnail images
- Featured Image Thumbnail Sizing
- How to modify Media Library images DPI [ image quality down to make small in size ] [closed]
- How to add text & call to action button to featured image on homepage?
- Featured image as background in a div using headway
- get_post_thumbnail_id() not getting correct featured image after post edited
- How to I remove Featured Image from the Posts/Category Lists?
- How do I change the size of the feature picture of a single post?