wordpress批量导入_如何从WordPress帖子中批量删除精选图片

wordpress批量导入

Recently one of our readers asked us how they can bulk remove featured images from posts in WordPress? At WPBeginner, we have discussed featured images (post thumbnails) many times. We showed you how to add featured images in WordPress, how to add new image sizes in WordPress, how to regenerate thumbnails, we even showed you how to add multiple featured images to a post in WordPress. In this article we will show you how to bulk remove featured images from posts in WordPress.

最近,我们的一位读者问我们如何从WordPress帖子中批量删除特色图片? 在WPBeginner,我们已经讨论了很多特色图片(缩略图)。 我们向您展示了如何在WordPress中添加特色图片 ,如何在WordPress添加新图片尺寸 ,如何重新生成缩略图 ,甚至还向您展示了如何向WordPress中的帖子添加多个特色图片 。 在本文中,我们将向您展示如何从WordPress帖子中批量删除特色图片。

批量删除帖子缩略图或精选图片的问题 (The Problem With Bulk Removal of Post Thumbnails or Featured Images)

Unfortunately, by default you can only remove featured images by editing each post and removing the featured image. Now if a user has hundreds of posts with featured images, then removing them one by one can be a very time consuming task. Instead, we are going to try a different approach. We will run a database query and unset the featured images on all posts.

不幸的是,默认情况下,您只能通过编辑每个帖子并删除特色图像来删除特色图像。 现在,如果用户有数百篇带有特色图片的帖子,那么将它们一一删除可能是非常耗时的任务。 相反,我们将尝试另一种方法。 我们将运行数据库查询,并取消所有帖子的特色图片。

Before you proceed, please note that the code below will remove featured images from all posts on your WordPress site by simply just pasting. Also note that this code will not delete any of your uploaded images, they will still be available in Media Library and you can reuse them anytime.

在继续之前,请注意,下面的代码只需粘贴即可从WordPress网站上的所有帖子中删除精选图片。 另请注意,此代码不会删除您上传的任何图像,它们仍将在Media Library中可用,您可以随时重复使用它们。

All you need to do is copy and paste this code in your theme’s functions.php file.

您需要做的就是将这段代码复制并粘贴到主题的functions.php文件中。



global $wpdb;
$wpdb->query( "
    DELETE FROM $wpdb->postmeta 
    WHERE meta_key = '_thumbnail_id'
" );

That’s all. As soon as you save your functions.php file this script will run a database query and remove featured images from all posts.

就这样。 一旦保存了functions.php文件,该脚本将运行数据库查询并从所有帖子中删除特色图像。

Important: Please remove this code immediately after saving your functions.php file. You will not be able to set featured images in WordPress as this code will keep removing featured images from posts.

重要提示:请保存您的functions.php文件后立即删除此代码。 您将无法在WordPress中设置特色图片,因为此代码将不断从帖子中删除特色图片。

We hope this article helped you save some time and allowed you to bulk remove featured images from WordPress posts. For questions and feedback please leave a comment below.

我们希望本文能帮助您节省一些时间,并允许您从WordPress帖子中批量删除特色图片。 对于问题和反馈,请在下面留下评论。

Source: Kaiser

资料来源: Kaiser

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-bulk-remove-featured-images-from-posts-in-wordpress/

wordpress批量导入

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值