Use wp_delete_attachment( $post_id )
if you have used wp_insert_attachment()
before.
$post_id
is the attachment ID.
If you haven’t used wp_insert_attachment()
a simple …
unlink( $upload['file'] );
… will do it.
Related Posts:
- Upload Multiple Files With media_handle_upload
- How to get the image EXIF date/time and use it for the WP post date/time
- How to save Uploaded image in custom option panel?
- Max file size not updating
- Why do I get undefined function export_wp()?
- Allowing SVG uploads in media uploader without plug-in
- Custom image size in Media Dropdown
- Images uploaded using media uploader are appearing upside down
- How can I enable uploading excel files?
- Can I hide certain upload folders in media library [duplicate]
- WordPress upload_mimes not working for front-end uploads of 3D files
- Disable auto-resizing of uploaded images, but only for certain filename
- When sale price is 0.00 show only regular price
- How to know which ajax file or function is called for action
- Can’t generate thumbnail images
- How to stop media_sideload_image from running when deleting a post?
- Possible to hook into Media Library preview File column and use a custom image?
- Function that prevents users from uploading photos more photos
- Is it possible to limit number of files a non-admin user can upload via the WordPress media library?
- How to add HTML into error message
- Serving cache from multiple domain names
- restrict uploaded image size and fixed image display size
- Function image_send_to_editor returns emty title tag
- Zip all (original) images from media gallery
- Figure inlined width trigger distorted layout
- wp_upload_bits – define (sub)folder / (sub)directory before filename?
- Rename file after title , one small problem
- When the WP_EDITOR button is pressed, the user is prompted to select a photo from their device
- How to overwrite image if it already exists – WordPress, Gravity form
- Convert Image to Webp on upload without plugin
- Add class to menu items of one specific menu (nav_menu_css_class)
- register_post_type for Pages?
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- How to get comments with mixed status using get_comments?
- Restrict user registration to emails on a single domain
- Call to undefined add_action() in theme’s functions.php
- How can I rename the WordPress AJAX URL? [duplicate]
- How to add a rel attribute to images that contains their categories?
- Is it possible to be more page/post specific with admin_enqueue_script?
- Can I use require() function in a template file?
- What is the most efficient method for loading widgets in functions.php
- Enqueue script o style only if a template part is loaded
- Can I pass two roles to the function get_users?
- Add external js file to footer with id
- password protected post policy
- Can’t write pdf file to upload directory using FPDF
- Logout hyperlink within a sub-menu
- Change the HTML of the comment form that is generating somewhere from the core WordPress
- How to customly read JWPlayer’s “Playlist” items by using its “playlistid”?
- Twentyten Child Theme: header images display messed up in admin panel
- How to get the index number of the posts?
- Removing wp_login_viewport_meta
- Get Current Post ID in functions php, meta query filter
- Call WordPress function outside of WordPress
- Move Custom Fields on General Settings Page to New Location
- Remove adjacent_posts_rel_link under 3.2?
- enqueue_script with filemtime javascript not working
- WP function won’t work on 404 template page
- How to obtain the recent posts without their content in an efficient way?
- Limit dimensions of “Full” size images
- Where to put random functions?
- Define PHP variable from a seperate API if statement
- Auto-Tweet if Type is ‘Status’ using OAuth
- Output a specific link in WordPress post if the single post’s category’s name contain certain word
- Passing user enetered value in widget: number of words, for example
- Adding a section in line at the end of the main navigation menu in php
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- Suggest Users basing on User taxonomy
- update_post_meta is Updating with two page id
- Custom Image Size in Insert Media
- Custom function for search form
- Custom Menu in Admin doesn’t change menu in browser
- How can I show different content for different user-levels?
- WordPress function bloginfo not echoing output on parts of the pages
- How to change a meta value (of a published post) after X days.?
- sort metabox columns in listing Single
- wp_nav_menu displaying all pages
- How to change text color depending on the number value (Using javascript)
- Why should I use get_template_directory() when include files?
- How to display an image before title text in menu items
- Error in “class-wp-hook.php”
- How to replace ACTION url from original wordpress login form?
- Redirect User Role When on Specific Page
- How to force one script to load before google tag manager script
- Ajax in plugin fails – but only on one blog – no idea why
- I can’t in any way include css in my theme using functions.php
- Problem with email function
- admin-ajax.php 403 forbidden only when calling from external file
- Display list of pages that contain a certain string within the slug
- I need to completely ‘wp_dequeue_script’; what’s the best way?
- $content is empty while using DOMDocument
- Change the second role depending on the first
- Problem with add_rewrite_tag
- getExcerpt: Make ellipsis appear only if character limit is reached
- Modify function Shortcode_atts
- How do I change the URL returned by next_posts_link()?
- WordPress SEO By Yoast Plugin is interfering with a custom function code – how to troubleshoot and fix it?
- Woocommerce – Checkout error message
- How to get postId from the argument $block when register_block_type()?
- comment_post function with js not running