Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wp_delete_attachment unlink

foreach ( $attachments as $attachment ) {
  if ( false === wp_delete_attachment( $attachment->ID, true ) ) {
    $file = get_attached_file( $attachment->ID );
    $file = str_replace( "uploads", "upload-assets", $file);
     wp_delete_file( $file );
   }
 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #unlink
ADD COMMENT
Topic
Name
7+2 =