📜  wp_delete_attachment unlink - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:58.199000             🧑  作者: Mango

代码示例1
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 );
   }
 }