wordpress建站后期,当我们想要删除文章的时候,发现文章里上传到媒体库的图片等附件并不会自动删除,这样占用了大量的网站空间,下面我们介绍一下在删除文章时自动删除缩略图以及图片附件的方法,只需几句简单的代码便可实现,不用手动去媒体库寻找并删除,准确率和效率都非常高。
切换到主题目录,打开functions.PHP文件,加入以下代码:
Crayon-5c891d2e529a3034651964" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">
Crayon-nums " data-settings="show"> Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"> Crayon-num" data-line="Crayon-5c891d2e529a3034651964-1">1 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-3">3 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-5">5 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-7">7 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-9">9 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-11">11 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-13">13 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-15">15 Crayon-num" data-line="Crayon-5c891d2e529a3034651964-17">17 | Crayon-code">