I have several empty img alt on my wordpress site (about 3k). After considering different solutions, looks like the best approach is to do a replace on the database. I would like to replace empty alt in post_content (alt="") with post_title (alt="This is the post title").
Something like that:
update wp_posts
set post_content = REPLACE(post_content,'alt=""', 'alt=" post_title "')
where post_status = 'publish';
But I don't get how to insert the post_title value in the query. Thank you for your help
CodePudding user response:
use a query like this:
UPDATE wp_posts
set post_content =
REPLACE(post_content,'alt=""', CONCAT('alt="', post_title, '"'))
WHERE post_status = 'publish';