简体   繁体   中英

Bulk Edit Sql Database - Remove Characters from Wordpress Image Captions

I'm working on a Wordpress project right now that involves hundreds of images. I've been uploading the images and setting the Captions and Alt text to the file names because I derped and thought the file name was a model number for each product.

It wasn't until after I uploaded about two hundred images that it dawned on me the LG in the image name stood for "Large Image" not a model number prefix. So now I need to go through and remove "LG" text from hundreds of alt text and caption fields.

Is there a sql command I can run to search all image captions and alt text for the characters LG and just remove those characters from captions and alt text?

For instance, a file name might be "LGWhite" so I set the caption and alt text to "LGWhite", when it should be just "White". How do I remove LG from everything in bulk?

UPDATE your_table
SET your_field = REPLACE(your_field, 'LG', '')
WHERE your_field = XX

you may not even need the where?

那这样的事呢

UPDATE `table` SET `column` = REPLACE(`column`, 'LG', '')

With normal SQL-Statements its very likely that you'll damage your Installation, because nearly everything is saved serialized in Wordpress. If you edit the length, it expects an X-Character Caption but will find only X-2 Characters :-/

There is a wonderful piece of software, made for making changes to Wordpress databases: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM