2-27 984
经历网站搬家的朋友一定知道,在更换域名之后wordpress的文章中特色图像会保留原来的域名路径,所以会出现无法加载的情况,甚是难看!所以到处找解决办法,终于找到批量删除特色图像的办法,供大家以后使用:
将下面的代码添加到当前主题的 functions.php :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/** * WordPress 批量删除所有文章的特色图像 * http://http://blog.liujason.com/archives/1024 */ global $wpdb; $attachments = $wpdb->get_results( " SELECT * FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' " ); foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->meta_value, true ); } $wpdb->query( " DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' " ); |
一旦你保存了 functions.php ,刷新页面之后所有文章的特色图像都会删除,但是只删除文章的特色图像设置数据(链接),假如图片在你的服务器上的话仍旧会保留在你的媒体库,不会删除的,执行了一次以后,马上删除这段代码,否则无法给文章再添加特色图像。
收藏备用
谢谢~
关注下了。
谢谢
我又长知识了
噫嘻嘻~新站如果不嫌弃的话求友链~
我的怎么样?
好啊好啊~
Pingback: payday loans online canada
Pingback: direct payday loans surrey bc canada lender
Pingback: drugrehabcentershotline.com rehab center
赞了
Pingback: Blue Coaster33
Pingback: watch tv show episodes
Pingback: tv online, online tv
Pingback: free movie downloads
Pingback: watch movies online free
Pingback: watch free movies online
Pingback: streaming movies
Pingback: watch free movies online
Pingback: stream movies
好东西 谢谢分享
长知识
Pingback: great prices on DIRECTV
Pingback: DIRECTV packages
Pingback: lan penge online nu
Pingback: mobile porn
Pingback: parking
Pingback: car parking
Pingback: water ionizer machine
Pingback: laan penge nu uden sikkerhed
Pingback: water ionizer pay plan loans
Pingback: plumber c of q ontario
Pingback: house blue