我的Wordpress网站有数百张具有以下属性的图片:
rel="lightbox" or rel=lightbox
所以,我的img src看起来像这样:
<img src="/image1.png" rel="lightbox">
或<img src="/image1.png" rel=lightbox>
我的网站上必须有超过2000张图片,而且我很确定将近500-600张这样的图片会有rel =&#34; lightbox&#34;或者rel =灯箱属性。
我的是MySQL数据库。
如何删除rel =&#34;灯箱&#34;或者rel =来自所有这些500-600张图片的灯箱?
答案 0 :(得分:0)
转到代码打印这些图像的位置,或者您可以在标题或正文部分中执行此操作: 你可以通过使用一些PHP代码来捕获它们:
<?php foreach ($imgs as $img) { ?>
<?php
if($img['rel'] != "lightbox")
{ ?>
你可以做任何你想要的网址打印。 像这样的img src与url和没有rel属性的东西
<img src="<?php echo $img['rel']; ?>" />
<?php } ?>
答案 1 :(得分:0)
备份数据库,然后运行以下SQL:
update wp_posts
set post_content = replace(post_content, ' rel="lightbox"', '')
where post_content like '% rel="lightbox"%';
update wp_posts
set post_content = replace(post_content, ' rel=lightbox', '')
where post_content like '% rel=lightbox%';
假设它只是您正在谈论的post_content
字段,并且您拥有默认的数据库前缀(wp_
)。